Azerotcore-wotlk
Player.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Affero General Public License as published by the
6  * Free Software Foundation; either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "AccountMgr.h"
19 #include "AchievementMgr.h"
20 #include "ArenaSpectator.h"
21 #include "ArenaTeam.h"
22 #include "ArenaTeamMgr.h"
23 #include "Battlefield.h"
24 #include "BattlefieldMgr.h"
25 #include "BattlefieldWG.h"
26 #include "Battleground.h"
27 #include "BattlegroundAV.h"
28 #include "BattlegroundMgr.h"
29 #include "CellImpl.h"
30 #include "Channel.h"
31 #include "ChannelMgr.h"
33 #include "Chat.h"
34 #include "Config.h"
35 #include "Common.h"
36 #include "ConditionMgr.h"
37 #include "CreatureAI.h"
38 #include "DatabaseEnv.h"
39 #include "DisableMgr.h"
40 #include "Formulas.h"
41 #include "GameEventMgr.h"
42 #include "GameGraveyard.h"
43 #include "GameObjectAI.h"
44 #include "GitRevision.h"
45 #include "GossipDef.h"
46 #include "GridNotifiers.h"
47 #include "GridNotifiersImpl.h"
48 #include "Group.h"
49 #include "GroupMgr.h"
50 #include "Guild.h"
51 #include "GuildMgr.h"
52 #include "InstanceSaveMgr.h"
53 #include "InstanceScript.h"
54 #include "Language.h"
55 #include "LFGMgr.h"
56 #include "Log.h"
57 #include "LootItemStorage.h"
58 #include "MapInstanced.h"
59 #include "MapMgr.h"
60 #include "ObjectAccessor.h"
61 #include "ObjectMgr.h"
62 #include "Opcodes.h"
63 #include "OutdoorPvP.h"
64 #include "OutdoorPvPMgr.h"
65 #include "Pet.h"
66 #include "PetitionMgr.h"
67 #include "Player.h"
68 #include "PoolMgr.h"
69 #include "QuestDef.h"
70 #include "QueryHolder.h"
71 #include "ReputationMgr.h"
72 #include "Realm.h"
73 #include "SavingSystem.h"
74 #include "ScriptMgr.h"
75 #include "SkillDiscovery.h"
76 #include "SocialMgr.h"
77 #include "Spell.h"
78 #include "SpellAuraEffects.h"
79 #include "SpellAuras.h"
80 #include "SpellMgr.h"
81 #include "TicketMgr.h"
82 #include "Transport.h"
83 #include "UpdateData.h"
84 #include "UpdateFieldFlags.h"
85 #include "UpdateMask.h"
86 #include "Util.h"
87 #include "Vehicle.h"
88 #include "Weather.h"
89 #include "WeatherMgr.h"
90 #include "World.h"
91 #include "WorldPacket.h"
92 #include "WorldSession.h"
93 
94 #ifdef ELUNA
95 #include "LuaEngine.h"
96 #endif
97 
99 {
100  CHARACTER_FLAG_NONE = 0x00000000,
101  CHARACTER_FLAG_UNK1 = 0x00000001,
102  CHARACTER_FLAG_UNK2 = 0x00000002,
104  CHARACTER_FLAG_UNK4 = 0x00000008,
105  CHARACTER_FLAG_UNK5 = 0x00000010,
106  CHARACTER_FLAG_UNK6 = 0x00000020,
107  CHARACTER_FLAG_UNK7 = 0x00000040,
108  CHARACTER_FLAG_UNK8 = 0x00000080,
109  CHARACTER_FLAG_UNK9 = 0x00000100,
110  CHARACTER_FLAG_UNK10 = 0x00000200,
113  CHARACTER_FLAG_UNK13 = 0x00001000,
114  CHARACTER_FLAG_GHOST = 0x00002000,
115  CHARACTER_FLAG_RENAME = 0x00004000,
116  CHARACTER_FLAG_UNK16 = 0x00008000,
117  CHARACTER_FLAG_UNK17 = 0x00010000,
118  CHARACTER_FLAG_UNK18 = 0x00020000,
119  CHARACTER_FLAG_UNK19 = 0x00040000,
120  CHARACTER_FLAG_UNK20 = 0x00080000,
121  CHARACTER_FLAG_UNK21 = 0x00100000,
122  CHARACTER_FLAG_UNK22 = 0x00200000,
123  CHARACTER_FLAG_UNK23 = 0x00400000,
124  CHARACTER_FLAG_UNK24 = 0x00800000,
127  CHARACTER_FLAG_UNK27 = 0x04000000,
128  CHARACTER_FLAG_UNK28 = 0x08000000,
129  CHARACTER_FLAG_UNK29 = 0x10000000,
130  CHARACTER_FLAG_UNK30 = 0x20000000,
131  CHARACTER_FLAG_UNK31 = 0x40000000,
132  CHARACTER_FLAG_UNK32 = 0x80000000
133 };
134 
136 {
138  CHAR_CUSTOMIZE_FLAG_CUSTOMIZE = 0x00000001, // name, gender, etc...
139  CHAR_CUSTOMIZE_FLAG_FACTION = 0x00010000, // name, gender, faction, etc...
140  CHAR_CUSTOMIZE_FLAG_RACE = 0x00100000 // name, gender, race, etc...
141 };
142 
143 static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 };
144 
145 // we can disable this warning for this since it only
146 // causes undefined behavior when passed to the base class constructor
147 #ifdef _MSC_VER
148 #pragma warning(disable:4355)
149 #endif
150 Player::Player(WorldSession* session): Unit(true), m_mover(this)
151 {
152 #ifdef _MSC_VER
153 #pragma warning(default:4355)
154 #endif
155 
156  m_speakTime = 0;
157  m_speakCount = 0;
158 
161 
163 
164  m_session = session;
165 
166  m_ingametime = 0;
167 
168  m_ExtraFlags = 0;
169 
170  m_spellModTakingSpell = nullptr;
171  //m_pad = 0;
172 
173  // players always accept
175  SetAcceptWhispers(true);
176 
177  m_comboPoints = 0;
178 
179  m_usedTalentCount = 0;
182 
183  m_regenTimer = 0;
184  m_regenTimerCount = 0;
187 
188  m_zoneUpdateId = uint32(-1);
189  m_zoneUpdateTimer = 0;
190 
191  m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
192 
193  m_areaUpdateId = 0;
195 
200 
202 
203  memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT);
204 
205  m_social = nullptr;
206 
207  // group is initialized in the reference constructor
208  SetGroupInvite(nullptr);
209  m_groupUpdateMask = 0;
211  m_bPassOnGroupLoot = false;
212 
213  duel = nullptr;
214 
215  m_GuildIdInvited = 0;
217 
219 
222 
224  m_bMustDelayTeleport = false;
225  m_bHasDelayedTeleport = false;
227 
228  m_trade = nullptr;
229 
230  m_cinematic = 0;
231 
234 
235  m_DailyQuestChanged = false;
237 
238  for (uint8 i = 0; i < MAX_TIMERS; i++)
240 
243  m_isInWater = false;
244  m_drunkTimer = 0;
245  m_deathTimer = 0;
246  m_deathExpireTime = 0;
247 
249 
250  m_swingErrorMsg = 0;
251 
252  for (uint8 j = 0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; ++j)
254 
255  m_logintime = time(nullptr);
260  m_ArmorProficiency = 0;
261  m_canParry = false;
262  m_canBlock = false;
263  m_canTitanGrip = false;
264  m_ammoDPS = 0.0f;
265 
267  //cache for UNIT_CREATED_BY_SPELL to allow
268  //returning reagents for temporarily removed pets
269  //when dying/logging out
270  m_oldpetspell = 0;
271  m_lastpetnumber = 0;
272 
274  _restTime = 0;
275  _innTriggerId = 0;
276  _restBonus = 0;
277  _restFlagMask = 0;
279 
280  m_mailsUpdated = false;
281  unReadMails = 0;
282  m_nextMailDelivereTime = time_t(0);
283 
284  m_resetTalentsCost = 0;
285  m_resetTalentsTime = 0;
286  m_itemUpdateQueueBlocked = false;
287 
288  for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
289  m_forced_speed_changes[i] = 0;
290 
291  m_stableSlots = 0;
292 
294 
295  m_HomebindTimer = 0;
296  m_InstanceValid = true;
300 
301  m_lastPotionId = 0;
302 
303  m_activeSpec = 0;
304  m_specsCount = 1;
305 
306  for (uint8 i = 0; i < MAX_TALENT_SPECS; ++i)
307  {
308  for (uint8 g = 0; g < MAX_GLYPH_SLOT_INDEX; ++g)
309  m_Glyphs[i][g] = 0;
310  }
311 
312  for (uint8 i = 0; i < BASEMOD_END; ++i)
313  {
314  m_auraBaseMod[i][FLAT_MOD] = 0.0f;
315  m_auraBaseMod[i][PCT_MOD] = 1.0f;
316  }
317 
318  for (uint8 i = 0; i < MAX_COMBAT_RATING; i++)
319  m_baseRatingValue[i] = 0;
320 
321  m_baseSpellPower = 0;
322  m_baseFeralAP = 0;
323  m_baseManaRegen = 0;
324  m_baseHealthRegen = 0;
326 
327  // Honor System
328  m_lastHonorUpdateTime = time(nullptr);
329 
330  m_IsBGRandomWinner = false;
331 
332  // Player summoning
333  m_summon_expire = 0;
334  m_summon_mapid = 0;
335  m_summon_x = 0.0f;
336  m_summon_y = 0.0f;
337  m_summon_z = 0.0f;
338  m_summon_asSpectator = false;
339 
340  //m_mover = this;
342  m_seer = this;
343 
344  m_recallMap = 0;
345  m_recallX = 0;
346  m_recallY = 0;
347  m_recallZ = 0;
348  m_recallO = 0;
349 
350  m_homebindMapId = 0;
351  m_homebindAreaId = 0;
352  m_homebindX = 0;
353  m_homebindY = 0;
354  m_homebindZ = 0;
355 
357 
358  m_declinedname = nullptr;
359 
360  m_isActive = true;
361 
362  m_runes = nullptr;
363 
364  m_lastFallTime = 0;
365  m_lastFallZ = 0;
366 
367  m_grantableLevels = 0;
368 
369  m_ControlledByPlayer = true;
370 
371  sWorld->IncreasePlayerCount();
372 
374 
375  for (uint8 i = 0; i < MAX_POWERS; ++i)
376  m_powerFraction[i] = 0;
377 
378  isDebugAreaTriggers = false;
379 
380  m_WeeklyQuestChanged = false;
381 
382  m_MonthlyQuestChanged = false;
383 
384  m_SeasonalQuestChanged = false;
385 
386  SetPendingBind(0, 0);
387 
389 
390  m_cinematicDiff = 0;
393  m_cinematicCamera = nullptr;
394  m_remoteSightPosition = Position(0.0f, 0.0f, 0.0f);
395  m_CinematicObject = nullptr;
396 
397  m_achievementMgr = new AchievementMgr(this);
398  m_reputationMgr = new ReputationMgr(this);
399 
400  // Ours
401  m_NeedToSaveGlyphs = false;
402  m_comboPointGain = 0;
403  m_MountBlockId = 0;
404  m_realDodge = 0.0f;
405  m_realParry = 0.0f;
408 
409  m_charmUpdateTimer = 0;
410 
411  for( int i = 0; i < NUM_CAI_SPELLS; ++i )
412  m_charmAISpells[i] = 0;
413 
414  m_applyResilience = true;
415 
416  m_isInstantFlightOn = true;
417 
418  sScriptMgr->OnConstructPlayer(this);
419 }
420 
422 {
423  sScriptMgr->OnDestructPlayer(this);
424 
425  // it must be unloaded already in PlayerLogout and accessed only for loggined player
426  //m_social = nullptr;
427 
428  // Note: buy back item already deleted from DB when player was saved
429  for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; ++i)
430  delete m_items[i];
431 
432  for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
433  delete itr->second;
434 
435  for (PlayerTalentMap::const_iterator itr = m_talents.begin(); itr != m_talents.end(); ++itr)
436  delete itr->second;
437 
438  //all mailed items should be deleted, also all mail should be deallocated
439  for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
440  {
441  delete *itr;
442  }
443 
444  for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter)
445  delete iter->second; //if item is duplicated... then server may crash ... but that item should be deallocated
446 
447  delete PlayerTalkClass;
448 
449  for (size_t x = 0; x < ItemSetEff.size(); x++)
450  delete ItemSetEff[x];
451 
452  delete m_declinedname;
453  delete m_runes;
454  delete m_achievementMgr;
455  delete m_reputationMgr;
456 
457  sWorld->DecreasePlayerCount();
458 
459  if (!m_isInSharedVisionOf.empty())
460  {
461  LOG_INFO("misc", "Player::~Player (A1)");
462  do
463  {
464  LOG_INFO("misc", "Player::~Player (A2)");
465  Unit* u = *(m_isInSharedVisionOf.begin());
466  u->RemovePlayerFromVision(this);
467  } while (!m_isInSharedVisionOf.empty());
468  }
469 }
470 
471 void Player::CleanupsBeforeDelete(bool finalCleanup)
472 {
473  TradeCancel(false);
475 
476  Unit::CleanupsBeforeDelete(finalCleanup);
477 }
478 
480 {
481  // FIXME: outfitId not used in player creating
482  // TODO: need more checks against packet modifications
483  // should check that skin, face, hair* are valid via DBC per race/class
484  // also do it in Player::BuildEnumData, Player::LoadFromDB
485 
486  Object::_Create(guidlow, 0, HighGuid::Player);
487 
488  m_name = createInfo->Name;
489 
490  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(createInfo->Race, createInfo->Class);
491  if (!info)
492  {
493  LOG_ERROR("entities.player", "Player::Create: Possible hacking-attempt: Account %u tried creating a character named '%s' with an invalid race/class pair (%u/%u) - refusing to do so.",
494  GetSession()->GetAccountId(), m_name.c_str(), createInfo->Race, createInfo->Class);
495  return false;
496  }
497 
498  for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; i++)
499  m_items[i] = nullptr;
500 
501  Relocate(info->positionX, info->positionY, info->positionZ, info->orientation);
502 
503  ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(createInfo->Class);
504  if (!cEntry)
505  {
506  LOG_ERROR("entities.player", "Player::Create: Possible hacking-attempt: Account %u tried creating a character named '%s' with an invalid character class (%u) - refusing to do so (wrong DBC-files?)",
507  GetSession()->GetAccountId(), m_name.c_str(), createInfo->Class);
508  return false;
509  }
510 
511  SetMap(sMapMgr->CreateMap(info->mapId, this));
512 
513  uint8 powertype = cEntry->powerType;
514 
515  SetObjectScale(1.0f);
516 
517  m_realRace = createInfo->Race; // set real race flag
518  m_race = createInfo->Race; // set real race flag
519 
520  SetFactionForRace(createInfo->Race);
521 
522  if (!IsValidGender(createInfo->Gender))
523  {
524  LOG_ERROR("entities.player", "Player::Create: Possible hacking-attempt: Account %u tried creating a character named '%s' with an invalid gender (%u) - refusing to do so",
525  GetSession()->GetAccountId(), m_name.c_str(), createInfo->Gender);
526  return false;
527  }
528 
529  uint32 RaceClassGender = (createInfo->Race) | (createInfo->Class << 8) | (createInfo->Gender << 16);
530 
531  SetUInt32Value(UNIT_FIELD_BYTES_0, (RaceClassGender | (powertype << 24)));
532  InitDisplayIds();
533  if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP)
534  {
537  }
539  SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client
540  SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // default for players in 3.0.3
541 
542  // -1 is default value
544 
545  SetUInt32Value(PLAYER_BYTES, (createInfo->Skin | (createInfo->Face << 8) | (createInfo->HairStyle << 16) | (createInfo->HairColor << 24)));
547  (0x00 << 8) |
548  (0x00 << 16) |
549  (((GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED) << 24)));
550  SetByteValue(PLAYER_BYTES_3, 0, createInfo->Gender);
551  SetByteValue(PLAYER_BYTES_3, 3, 0); // BattlefieldArenaFaction (0 or 1)
552 
556 
557  for (int i = 0; i < KNOWN_TITLES_SIZE; ++i)
558  SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES + i, 0); // 0=disabled
560 
565 
566  // set starting level
567  uint32 start_level = getClass() != CLASS_DEATH_KNIGHT
568  ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)
569  : sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL);
570 
572  {
573  uint32 gm_level = sWorld->getIntConfig(CONFIG_START_GM_LEVEL);
574  if (gm_level > start_level)
575  start_level = gm_level;
576  }
577 
578  SetUInt32Value(UNIT_FIELD_LEVEL, start_level);
579 
580  InitRunes();
581 
585 
586  // start with every map explored
587  if (sWorld->getBoolConfig(CONFIG_START_ALL_EXPLORED))
588  {
589  for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; i++)
590  SetFlag(PLAYER_EXPLORED_ZONES_1 + i, 0xFFFFFFFF);
591  }
592 
593  // Played time
594  m_Last_tick = time(nullptr);
597 
598  // base stats and related field values
603  InitPrimaryProfessions(); // to max set before any spell added
604 
606 
607  // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
608  UpdateMaxHealth(); // Update max Health (for add bonus from stamina)
609  SetFullHealth();
610  if (getPowerType() == POWER_MANA)
611  {
612  UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intellect)
614  }
615 
617  {
618  SetPower(POWER_RUNE, 8);
622  }
623 
624  // original spells
627 
628  // original action bar
629  for (PlayerCreateInfoActions::const_iterator action_itr = info->action.begin(); action_itr != info->action.end(); ++action_itr)
630  addActionButton(action_itr->button, action_itr->action, action_itr->type);
631 
632  // original items
633  if (CharStartOutfitEntry const* oEntry = GetCharStartOutfitEntry(createInfo->Race, createInfo->Class, createInfo->Gender))
634  {
635  for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
636  {
637  if (oEntry->ItemId[j] <= 0)
638  continue;
639 
640  uint32 itemId = oEntry->ItemId[j];
641 
642  // just skip, reported in ObjectMgr::LoadItemTemplates
643  ItemTemplate const* iProto = sObjectMgr->GetItemTemplate(itemId);
644  if (!iProto)
645  continue;
646 
647  // BuyCount by default
648  uint32 count = iProto->BuyCount;
649 
650  // special amount for food/drink
651  if (iProto->Class == ITEM_CLASS_CONSUMABLE && iProto->SubClass == ITEM_SUBCLASS_FOOD)
652  {
653  switch (iProto->Spells[0].SpellCategory)
654  {
655  case SPELL_CATEGORY_FOOD: // food
656  count = getClass() == CLASS_DEATH_KNIGHT ? 10 : 4;
657  break;
658  case SPELL_CATEGORY_DRINK: // drink
659  count = 2;
660  break;
661  }
662  if (iProto->GetMaxStackSize() < count)
663  count = iProto->GetMaxStackSize();
664  }
665  StoreNewItemInBestSlots(itemId, count);
666  }
667  }
668 
669  for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr)
670  StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount);
671 
672  // bags and main-hand weapon must equipped at this moment
673  // now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon)
674  // or ammo not equipped in special bag
676  {
677  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
678  {
679  uint16 eDest;
680  // equip offhand weapon/shield if it attempt equipped before main-hand weapon
681  InventoryResult msg = CanEquipItem(NULL_SLOT, eDest, pItem, false);
682  if (msg == EQUIP_ERR_OK)
683  {
685  EquipItem(eDest, pItem, true);
686  }
687  // move other items to more appropriate slots (ammo not equipped in special bag)
688  else
689  {
690  ItemPosCountVec sDest;
691  msg = CanStoreItem(NULL_BAG, NULL_SLOT, sDest, pItem, false);
692  if (msg == EQUIP_ERR_OK)
693  {
695  pItem = StoreItem(sDest, pItem, true);
696  }
697 
698  // if this is ammo then use it
699  msg = CanUseAmmo(pItem->GetEntry());
700  if (msg == EQUIP_ERR_OK)
701  SetAmmo(pItem->GetEntry());
702  }
703  }
704  }
705  // all item positions resolved
706 
708 
709  return true;
710 }
711 
712 bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount)
713 {
714  LOG_DEBUG("entities.player.items", "STORAGE: Creating initial item, itemId = %u, count = %u", titem_id, titem_amount);
715 
716  // attempt equip by one
717  while (titem_amount > 0)
718  {
719  uint16 eDest;
720  InventoryResult msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false);
721  if (msg != EQUIP_ERR_OK)
722  break;
723 
724  EquipNewItem(eDest, titem_id, true);
726  --titem_amount;
727  }
728 
729  if (titem_amount == 0)
730  return true; // equipped
731 
732  // attempt store
733  ItemPosCountVec sDest;
734  // store in main bag to simplify second pass (special bags can be not equipped yet at this moment)
735  InventoryResult msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount);
736  if (msg == EQUIP_ERR_OK)
737  {
738  StoreNewItem(sDest, titem_id, true);
739  return true; // stored
740  }
741 
742  // item can't be added
743  LOG_ERROR("entities.player", "STORAGE: Can't equip or store initial item %u for race %u class %u, error msg = %u", titem_id, getRace(true), getClass(), msg);
744  return false;
745 }
746 
747 void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen)
748 {
749  if (int(MaxValue) == DISABLED_MIRROR_TIMER)
750  {
751  if (int(CurrentValue) != DISABLED_MIRROR_TIMER)
752  StopMirrorTimer(Type);
753  return;
754  }
756  data << (uint32)Type;
757  data << CurrentValue;
758  data << MaxValue;
759  data << Regen;
760  data << (uint8)0;
761  data << (uint32)0; // spell id
762  GetSession()->SendPacket(&data);
763 }
764 
766 {
769  data << (uint32)Type;
770  GetSession()->SendPacket(&data);
771 }
772 
774 {
775  // check for GM and death state included in isAttackableByAOE
776  return (!isTargetableForAttack(false, nullptr)) || isTotalImmune();
777 }
778 
780 {
782  return 0;
783 
784  // Absorb, resist some environmental damage type
785  uint32 absorb = 0;
786  uint32 resist = 0;
787 
788  switch (type)
789  {
790  case DAMAGE_LAVA:
791  case DAMAGE_SLIME:
792  {
793  DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE);
794  Unit::CalcAbsorbResist(dmgInfo);
795  absorb = dmgInfo.GetAbsorb();
796  resist = dmgInfo.GetResist();
797  damage = dmgInfo.GetDamage();
798  }
799  default:
800  break;
801  }
802 
803  Unit::DealDamageMods(this, damage, &absorb);
804 
806  data << GetGUID();
807  data << uint8(type != DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL);
808  data << uint32(damage);
809  data << uint32(absorb);
810  data << uint32(resist);
811  SendMessageToSet(&data, true);
812 
813  uint32 final_damage = Unit::DealDamage(this, this, damage, nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
814 
815  if (!IsAlive())
816  {
817  if (type == DAMAGE_FALL) // DealDamage not apply item durability loss at self damage
818  {
819  LOG_DEBUG("entities.player", "We are fall to death, loosing 10 percents durability");
820  DurabilityLossAll(0.10f, false);
821  // durability lost message
823  GetSession()->SendPacket(&data2);
824  }
825 
827  }
828 
829  return final_damage;
830 }
831 
833 {
834  switch (timer)
835  {
836  case FATIGUE_TIMER:
837  return MINUTE * IN_MILLISECONDS;
838  case BREATH_TIMER:
839  {
841  return DISABLED_MIRROR_TIMER;
842  int32 UnderWaterTime = 3 * MINUTE * IN_MILLISECONDS;
844  for (AuraEffectList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i)
845  AddPct(UnderWaterTime, (*i)->GetAmount());
846  return UnderWaterTime;
847  }
848  case FIRE_TIMER:
849  {
850  if (!IsAlive())
851  return DISABLED_MIRROR_TIMER;
852  return 1 * IN_MILLISECONDS;
853  }
854  default:
855  return 0;
856  }
857 }
858 
860 {
861  if (!m_MirrorTimerFlags)
862  return;
863 
864  // In water
866  {
867  // Breath timer not activated - activate it
869  {
872  }
873  else // If activated - do tick
874  {
875  m_MirrorTimer[BREATH_TIMER] -= time_diff;
876  // Timer limit - need deal damage
877  if (m_MirrorTimer[BREATH_TIMER] < 0)
878  {
880  // Calculate and deal damage
881  // TODO: Check this formula
882  uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1);
884  }
885  else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need
887  }
888  }
889  else if (m_MirrorTimer[BREATH_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer
890  {
891  int32 UnderWaterTime = getMaxTimer(BREATH_TIMER);
892  // Need breath regen
893  m_MirrorTimer[BREATH_TIMER] += 10 * time_diff;
894  if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive())
898  }
899 
900  // In dark water
902  {
903  // Fatigue timer not activated - activate it
905  {
908  }
909  else
910  {
911  m_MirrorTimer[FATIGUE_TIMER] -= time_diff;
912  // Timer limit - need deal damage or teleport ghost to graveyard
913  if (m_MirrorTimer[FATIGUE_TIMER] < 0)
914  {
916  if (IsAlive()) // Calculate and deal damage
917  {
918  uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1);
920  }
921  else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
923  }
926  }
927  }
928  else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer
929  {
930  int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER);
931  m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff;
932  if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive())
936  }
937 
938  if (m_MirrorTimerFlags & (UNDERWATER_INLAVA /*| UNDERWATER_INSLIME*/) && !(_lastLiquid && _lastLiquid->SpellId))
939  {
940  // Breath timer not activated - activate it
943  else
944  {
945  m_MirrorTimer[FIRE_TIMER] -= time_diff;
946  if (m_MirrorTimer[FIRE_TIMER] < 0)
947  {
949  // Calculate and deal damage
950  // TODO: Check this formula
951  uint32 damage = urand(600, 700);
954  // need to skip Slime damage in Undercity,
955  // maybe someone can find better way to handle environmental damage
956  //else if (m_zoneUpdateId != 1497)
957  // EnvironmentalDamage(DAMAGE_SLIME, damage);
958  }
959  }
960  }
961  else
963 
964  // Recheck timers flag
966  for (uint8 i = 0; i < MAX_TIMERS; ++i)
968  {
970  break;
971  }
973 }
974 
977 {
978  m_drunkTimer = 0;
979 
980  uint8 currentDrunkValue = GetDrunkValue();
981  uint8 drunk = currentDrunkValue ? --currentDrunkValue : 0;
982  SetDrunkValue(drunk);
983 }
984 
986 {
987  if (value >= 90)
988  return DRUNKEN_SMASHED;
989  if (value >= 50)
990  return DRUNKEN_DRUNK;
991  if (value)
992  return DRUNKEN_TIPSY;
993  return DRUNKEN_SOBER;
994 }
995 
996 void Player::SetDrunkValue(uint8 newDrunkValue, uint32 itemId /*= 0*/)
997 {
998  bool isSobering = newDrunkValue < GetDrunkValue();
1000  if (newDrunkValue > 100)
1001  newDrunkValue = 100;
1002 
1003  // select drunk percent or total SPELL_AURA_MOD_FAKE_INEBRIATE amount, whichever is higher for visibility updates
1004  int32 drunkPercent = std::max<int32>(newDrunkValue, GetTotalAuraModifier(SPELL_AURA_MOD_FAKE_INEBRIATE));
1005  if (drunkPercent)
1006  {
1009  }
1010  else if (!HasAuraType(SPELL_AURA_MOD_FAKE_INEBRIATE) && !newDrunkValue)
1012 
1013  uint32 newDrunkenState = Player::GetDrunkenstateByValue(newDrunkValue);
1014  SetByteValue(PLAYER_BYTES_3, 1, newDrunkValue);
1015  UpdateObjectVisibility(false);
1016 
1017  if (!isSobering)
1018  m_drunkTimer = 0; // reset sobering timer
1019 
1020  if (newDrunkenState == oldDrunkenState)
1021  return;
1022 
1024  data << GetGUID();
1025  data << uint32(newDrunkenState);
1026  data << uint32(itemId);
1027  SendMessageToSet(&data, true);
1028 }
1029 
1030 void Player::setDeathState(DeathState s, bool /*despawn = false*/)
1031 {
1032  uint32 ressSpellId = 0;
1033 
1034  bool cur = IsAlive();
1035 
1036  if (s == JUST_DIED)
1037  {
1038  if (!cur)
1039  {
1040  LOG_ERROR("entities.player", "setDeathState: attempt to kill a dead player %s (%s)", GetName().c_str(), GetGUID().ToString().c_str());
1041  return;
1042  }
1043 
1044  // drunken state is cleared on death
1045  SetDrunkValue(0);
1046  // lost combo points at any target (targeted combo points clear in Unit::setDeathState)
1047  ClearComboPoints();
1048 
1050 
1051  //FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD)
1052  RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
1053 
1054  // save value before aura remove in Unit::setDeathState
1055  ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL);
1056 
1057  // xinef: disable passive area auras!
1059 
1060  // passive spell
1061  if (!ressSpellId)
1062  ressSpellId = GetResurrectionSpellId();
1066 
1067  // Xinef: reset all death criterias
1069  }
1070  // xinef: enable passive area auras!
1071  else if (s == ALIVE)
1073 
1075 
1076  if (NeedSendSpectatorData())
1078 
1079  // restore resurrection spell id for player after aura remove
1080  if (s == JUST_DIED && cur && ressSpellId)
1081  SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId);
1082 
1083  if (IsAlive() && !cur)
1084  //clear aura case after resurrection by another way (spells will be applied before next death)
1086 }
1087 
1089 {
1090  _innTriggerId = triggerId;
1091  _restTime = time(nullptr);
1093 }
1094 
1096 {
1097  _innTriggerId = 0;
1098  _restTime = 0;
1100 }
1101 
1103 {
1104  // 0 1 2 3 4 5 6 7
1105  // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.skin, characters.face, characters.hairStyle,
1106  // 8 9 10 11 12 13 14 15
1107  // characters.hairColor, characters.facialStyle, character.level, characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z,
1108  // 16 17 18 19 20 21 22 23
1109  // guild_member.guildid, characters.playerFlags, characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, character_banned.guid,
1110  // 24 25
1111  // characters.extra_flags, character_declinedname.genitive
1112 
1113  Field* fields = result->Fetch();
1114 
1115  ObjectGuid::LowType guidLow = fields[0].GetUInt32();
1116  uint8 plrRace = fields[2].GetUInt8();
1117  uint8 plrClass = fields[3].GetUInt8();
1118  uint8 gender = fields[4].GetUInt8();
1119 
1120  ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(guidLow);
1121 
1122  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(plrRace, plrClass);
1123  if (!info)
1124  {
1125  LOG_ERROR("entities.player", "Player %s has incorrect race/class pair. Don't build enum.", guid.ToString().c_str());
1126  return false;
1127  }
1128  else if (!IsValidGender(gender))
1129  {
1130  LOG_ERROR("entities.player", "Player (%s) has incorrect gender (%u), don't build enum.", guid.ToString().c_str(), gender);
1131  return false;
1132  }
1133 
1134  *data << guid;
1135  *data << fields[1].GetString(); // name
1136  *data << uint8(plrRace); // race
1137  *data << uint8(plrClass); // class
1138  *data << uint8(gender); // gender
1139 
1140  uint8 skin = fields[5].GetUInt8();
1141  uint8 face = fields[6].GetUInt8();
1142  uint8 hairStyle = fields[7].GetUInt8();
1143  uint8 hairColor = fields[8].GetUInt8();
1144  uint8 facialStyle = fields[9].GetUInt8();
1145 
1146  uint32 charFlags = 0;
1147  uint32 playerFlags = fields[17].GetUInt32();
1148  uint16 atLoginFlags = fields[18].GetUInt16();
1149  uint32 zone = (atLoginFlags & AT_LOGIN_FIRST) != 0 ? 0 : fields[11].GetUInt16(); // if first login do not show the zone
1150 
1151  *data << uint8(skin);
1152  *data << uint8(face);
1153  *data << uint8(hairStyle);
1154  *data << uint8(hairColor);
1155  *data << uint8(facialStyle);
1156 
1157  *data << uint8(fields[10].GetUInt8()); // level
1158  *data << uint32(zone); // zone
1159  *data << uint32(fields[12].GetUInt16()); // map
1160 
1161  *data << fields[13].GetFloat(); // x
1162  *data << fields[14].GetFloat(); // y
1163  *data << fields[15].GetFloat(); // z
1164 
1165  *data << uint32(fields[16].GetUInt32()); // guild id
1166 
1167  if (atLoginFlags & AT_LOGIN_RESURRECT)
1168  playerFlags &= ~PLAYER_FLAGS_GHOST;
1169  if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
1170  charFlags |= CHARACTER_FLAG_HIDE_HELM;
1171  if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
1172  charFlags |= CHARACTER_FLAG_HIDE_CLOAK;
1173  if (playerFlags & PLAYER_FLAGS_GHOST)
1174  charFlags |= CHARACTER_FLAG_GHOST;
1175  if (atLoginFlags & AT_LOGIN_RENAME)
1176  charFlags |= CHARACTER_FLAG_RENAME;
1177  if (fields[23].GetUInt32())
1178  charFlags |= CHARACTER_FLAG_LOCKED_BY_BILLING;
1179  if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
1180  {
1181  if (!fields[25].GetString().empty())
1182  charFlags |= CHARACTER_FLAG_DECLINED;
1183  }
1184  else
1185  charFlags |= CHARACTER_FLAG_DECLINED;
1186 
1187  *data << uint32(charFlags); // character flags
1188 
1189  // character customize flags
1190  if (atLoginFlags & AT_LOGIN_CUSTOMIZE)
1192  else if (atLoginFlags & AT_LOGIN_CHANGE_FACTION)
1194  else if (atLoginFlags & AT_LOGIN_CHANGE_RACE)
1195  *data << uint32(CHAR_CUSTOMIZE_FLAG_RACE);
1196  else
1197  *data << uint32(CHAR_CUSTOMIZE_FLAG_NONE);
1198 
1199  // First login
1200  *data << uint8(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0);
1201 
1202  // Pets info
1203  uint32 petDisplayId = 0;
1204  uint32 petLevel = 0;
1205  uint32 petFamily = 0;
1206 
1207  // show pet at selection character in character list only for non-ghost character
1208  if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (plrClass == CLASS_WARLOCK || plrClass == CLASS_HUNTER || (plrClass == CLASS_DEATH_KNIGHT && (fields[21].GetUInt32()&PLAYER_EXTRA_SHOW_DK_PET))))
1209  {
1210  uint32 entry = fields[19].GetUInt32();
1211  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(entry);
1212  if (creatureInfo)
1213  {
1214  petDisplayId = fields[20].GetUInt32();
1215  petLevel = fields[21].GetUInt16();
1216  petFamily = creatureInfo->family;
1217  }
1218  }
1219 
1220  *data << uint32(petDisplayId);
1221  *data << uint32(petLevel);
1222  *data << uint32(petFamily);
1223 
1224  Tokenizer equipment(fields[22].GetString(), ' ');
1225  for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_END; ++slot)
1226  {
1227  uint32 visualBase = slot * 2;
1228  uint32 itemId = GetUInt32ValueFromArray(equipment, visualBase);
1229  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
1230  if (!proto)
1231  {
1232  *data << uint32(0);
1233  *data << uint8(0);
1234  *data << uint32(0);
1235  continue;
1236  }
1237 
1238  SpellItemEnchantmentEntry const* enchant = nullptr;
1239 
1240  uint32 enchants = GetUInt32ValueFromArray(equipment, visualBase + 1);
1241  for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
1242  {
1243  // values stored in 2 uint16
1244  uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
1245  if (!enchantId)
1246  continue;
1247 
1248  enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
1249  if (enchant)
1250  break;
1251  }
1252 
1253  *data << uint32(proto->DisplayInfoID);
1254  *data << uint8(proto->InventoryType);
1255  *data << uint32(enchant ? enchant->aura_id : 0);
1256  }
1257 
1258  return true;
1259 }
1260 
1262 {
1264 
1265  // afk player not allowed in battleground
1266  if (isAFK() && InBattleground() && !InArena())
1268 }
1269 
1271 {
1273 }
1274 
1276 {
1277  uint8 tag = CHAT_TAG_NONE;
1278 
1279  if (isGMChat())
1280  tag |= CHAT_TAG_GM;
1281  if (isDND())
1282  tag |= CHAT_TAG_DND;
1283  if (isAFK())
1284  tag |= CHAT_TAG_AFK;
1285  if (IsDeveloper())
1286  tag |= CHAT_TAG_DEV;
1287 
1288  return tag;
1289 }
1290 
1292 {
1294  data << GetPackGUID();
1295  data << uint32(0); // this value increments every time
1296  BuildMovementPacket(&data);
1297  GetSession()->SendPacket(&data);
1298 }
1299 
1300 bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*= 0*/, Unit* target /*= nullptr*/, bool newInstance /*= false*/)
1301 {
1302  // for except kick by antispeedhack
1303  sScriptMgr->AnticheatSetSkipOnePacketForASH(this, true);
1304 
1305  if (!MapMgr::IsValidMapCoord(mapid, x, y, z, orientation))
1306  {
1307  LOG_ERROR("entities.player", "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (%s, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).",
1308  mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
1309  return false;
1310  }
1311 
1313  {
1314  LOG_ERROR("entities.player", "Player (%s, name: %s) tried to enter a forbidden map %u", GetGUID().ToString().c_str(), GetName().c_str(), mapid);
1316  return false;
1317  }
1318 
1319  // preparing unsummon pet if lost (we must get pet before teleportation or will not find it later)
1320  Pet* pet = GetPet();
1321 
1322  MapEntry const* mEntry = sMapStore.LookupEntry(mapid);
1323 
1324  // don't let enter battlegrounds without assigned battleground id (for example through areatrigger)...
1325  if (!InBattleground() && mEntry->IsBattlegroundOrArena())
1326  return false;
1327 
1328  // pussywizard: arena spectator, prevent teleporting from arena to instance/etc
1329  if (GetMapId() != mapid && IsSpectator() && mEntry->Instanceable())
1330  {
1332  return false;
1333  }
1334 
1335  // client without expansion support
1336  if (GetSession()->Expansion() < mEntry->Expansion())
1337  {
1338  LOG_DEBUG("maps", "Player %s using client without required expansion tried teleport to non accessible map %u", GetName().c_str(), mapid);
1339 
1340  if (GetTransport())
1341  {
1343  m_transport = nullptr;
1346  RepopAtGraveyard(); // teleport to near graveyard if on transport, looks blizz like :)
1347  }
1348 
1350 
1351  return false; // normal client can't teleport to this map...
1352  }
1353  else
1354  LOG_DEBUG("maps", "Player %s is being teleported to map %u", GetName().c_str(), mapid);
1355 
1356  // xinef: do this here in case teleport failed in above checks
1357  if (!(options & TELE_TO_NOT_LEAVE_TAXI) && IsInFlight())
1358  {
1361  }
1362 
1363  if (!(options & TELE_TO_NOT_LEAVE_VEHICLE) && m_vehicle)
1364  ExitVehicle();
1365 
1366  // reset movement flags at teleport, because player will continue move with these flags after teleport
1368  DisableSpline();
1369 
1370  // Xinef: Remove all movement imparing effects auras, skip small teleport like blink
1371  if (mapid != GetMapId() || GetDistance2d(x, y) > 100)
1372  {
1377  }
1378 
1379  if (m_transport)
1380  {
1381  if (options & TELE_TO_NOT_LEAVE_TRANSPORT)
1383  else
1384  {
1386  m_transport = nullptr;
1389  }
1390  }
1391 
1392  // The player was ported to another map and loses the duel immediately.
1393  // We have to perform this check before the teleport, otherwise the
1394  // ObjectAccessor won't find the flag.
1397 
1398  if (!sScriptMgr->OnBeforePlayerTeleport(this, mapid, x, y, z, orientation, options, target))
1399  return false;
1400 
1401  if (GetMapId() == mapid && !newInstance)
1402  {
1403  //lets reset far teleport flag if it wasn't reset during chained teleports
1405 
1406  SetHasDelayedTeleport(false); // pussywizard: current teleport cancels stored one
1407  //if teleport spell is casted in Unit::Update() func
1408  //then we need to delay it until update process will be finished
1409  if (MustDelayTeleport())
1410  {
1411  SetHasDelayedTeleport(true);
1412  SetSemaphoreTeleportNear(time(nullptr));
1413  //lets save teleport destination for player
1414  teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
1415  teleportStore_options = options;
1416  return true;
1417  }
1418 
1419  if (options & TELE_TO_WITH_PET)
1421 
1422  if (!(options & TELE_TO_NOT_UNSUMMON_PET))
1423  {
1424  //same map, only remove pet if out of range for new position
1425  if (pet && !pet->IsWithinDist3d(x, y, z, GetMap()->GetVisibilityRange()))
1427  }
1428 
1429  if (!(options & TELE_TO_NOT_LEAVE_COMBAT))
1430  CombatStop();
1431 
1432  // this will be used instead of the current location in SaveToDB
1433  teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
1434  SetFallInformation(time(nullptr), z);
1435 
1436  // code for finish transfer called in WorldSession::HandleMovementOpcodes()
1437  // at client packet MSG_MOVE_TELEPORT_ACK
1438  SetSemaphoreTeleportNear(time(nullptr));
1439  // near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
1440  if (!GetSession()->PlayerLogout())
1441  {
1442  Position oldPos = GetPosition();
1443  Relocate(x, y, z, orientation);
1445  SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
1446  }
1447  }
1448  else
1449  {
1450  if (getClass() == CLASS_DEATH_KNIGHT && GetMapId() == 609 && !IsGameMaster() && !HasSpell(50977))
1451  return false;
1452 
1453  // far teleport to another map
1454  Map* oldmap = IsInWorld() ? GetMap() : nullptr;
1455  // check if we can enter before stopping combat / removing pet / totems / interrupting spells
1456 
1457  // Check enter rights before map getting to avoid creating instance copy for player
1458  // this check not dependent from map instance copy and same for all instance copies of selected map
1459  if (!(options & TELE_TO_GM_MODE) && sMapMgr->PlayerCannotEnter(mapid, this, false))
1460  return false;
1461 
1462  // if PlayerCannotEnter -> CanEnter: checked above
1463  {
1464  //lets reset near teleport flag if it wasn't reset during chained teleports
1466 
1467  SetHasDelayedTeleport(false); // pussywizard: current teleport cancels stored one
1468  //if teleport spell is casted in Unit::Update() func
1469  //then we need to delay it until update process will be finished
1470  if (MustDelayTeleport())
1471  {
1472  SetHasDelayedTeleport(true);
1473  SetSemaphoreTeleportFar(time(nullptr));
1474  //lets save teleport destination for player
1475  teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
1476  teleportStore_options = options;
1477  return true;
1478  }
1479 
1481 
1482  CombatStop();
1483 
1484  // remove arena spell coldowns/buffs now to also remove pet's cooldowns before it's temporarily unsummoned
1486  {
1487  // KEEP THIS ORDER!
1488  RemoveArenaAuras();
1489  if (pet)
1490  pet->RemoveArenaAuras();
1491 
1493  }
1494 
1495  // remove pet on map change
1496  if (pet)
1498 
1499  // remove all dyn objects
1501 
1502  // stop spellcasting
1503  // not attempt interrupt teleportation spell at caster teleport
1504  if (!(options & TELE_TO_SPELL))
1505  if (IsNonMeleeSpellCast(true))
1507 
1508  //remove auras before removing from map...
1510 
1511  if (!GetSession()->PlayerLogout())
1512  {
1513  // send transfer packets
1514  WorldPacket data(SMSG_TRANSFER_PENDING, 4 + 4 + 4);
1515  data << uint32(mapid);
1516  if (m_transport)
1517  data << m_transport->GetEntry() << GetMapId();
1518 
1519  GetSession()->SendPacket(&data);
1520  }
1521 
1522  // remove from old map now
1523  if (oldmap)
1524  oldmap->RemovePlayerFromMap(this, false);
1525 
1526  // xinef: do this before setting fall information!
1527  if (IsMounted() && (!GetMap()->GetEntry()->IsDungeon() && !GetMap()->GetEntry()->IsBattlegroundOrArena()))
1528  {
1530  if (!auras.empty())
1531  {
1532  SetMountBlockId((*auras.begin())->GetId());
1534  }
1535  }
1536 
1537  teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
1538  SetFallInformation(time(nullptr), z);
1539  // if the player is saved before worldportack (at logout for example)
1540  // this will be used instead of the current location in SaveToDB
1541 
1542  if (!GetSession()->PlayerLogout())
1543  {
1544  WorldPacket data(SMSG_NEW_WORLD, 4 + 4 + 4 + 4 + 4);
1545  data << uint32(mapid);
1546  if (m_transport)
1548  else
1550 
1551  GetSession()->SendPacket(&data);
1553  }
1554 
1555  // move packet sent by client always after far teleport
1556  // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet
1557  SetSemaphoreTeleportFar(time(nullptr));
1558  }
1559  }
1560  return true;
1561 }
1562 
1564 {
1568 
1571 
1572  if (loc.m_mapId == MAPID_INVALID)
1573  {
1575  }
1576 
1577  return TeleportTo(loc);
1578 }
1579 
1581 {
1582  if (m_DelayedOperations == 0)
1583  return;
1584 
1586  {
1587  ResurrectPlayer(0.0f, false);
1588 
1591  else
1592  SetFullHealth();
1593 
1596  else
1598 
1599  SetPower(POWER_RAGE, 0);
1601 
1602  SpawnCorpseBones();
1603  }
1604 
1606  SaveToDB(false, false);
1607 
1609  CastSpell(this, 26013, true); // Deserter
1610 
1612  {
1614  {
1615  // xinef: remove shapeshift auras
1617  {
1619  }
1622  }
1623  }
1624 
1626  {
1628  {
1629  for (size_t i = 0; i < m_entryPointData.taxiPath.size() - 1; ++i)
1632 
1635  }
1636  }
1637 
1639  {
1640  if (Group* g = GetGroup())
1641  g->SendUpdateToPlayer(GetGUID());
1642  }
1643 
1645  {
1646  if (Vehicle* vehicle = GetVehicle())
1647  {
1648  SeatMap::iterator itr = vehicle->GetSeatIteratorForPassenger(this);
1649  if (itr != vehicle->Seats.end())
1650  if (Unit* base = vehicle->GetBase())
1651  {
1652  ExitVehicle();
1653  base->HandleSpellClick(this, itr->first);
1654  }
1655  }
1656  }
1657 
1658  //we have executed ALL delayed ops, so clear the flag
1659  m_DelayedOperations = 0;
1660 }
1661 
1663 {
1667  Unit::AddToWorld();
1668 
1669  for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
1670  if (m_items[i])
1671  m_items[i]->AddToWorld();
1672 }
1673 
1675 {
1676  // cleanup
1677  if (IsInWorld())
1678  {
1680  StopCastingCharm();
1683  ClearComboPoints(); // pussywizard: crashfix
1684  ClearComboPointHolders(); // pussywizard: crashfix
1685  if (ObjectGuid lguid = GetLootGUID()) // pussywizard: crashfix
1686  m_session->DoLootRelease(lguid);
1687  sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
1688  sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
1689  }
1690 
1691  // Remove items from world before self - player must be found in Item::RemoveFromObjectUpdate
1692  for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
1693  {
1694  if (m_items[i])
1695  m_items[i]->RemoveFromWorld();
1696  }
1697 
1698  for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter)
1699  iter->second->RemoveFromWorld();
1700 
1705 
1706  if (m_uint32Values)
1707  {
1708  if (WorldObject* viewpoint = GetViewpoint())
1709  {
1710  LOG_FATAL("entities.player", "Player %s has viewpoint %u %u when removed from world", GetName().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId());
1711  SetViewpoint(viewpoint, false);
1712  }
1713  }
1714 }
1715 
1717 {
1718  //if (m_regenTimer <= 500)
1719  // return;
1720 
1723 
1725 
1727 
1728  // Runes act as cooldowns, and they don't need to send any data
1729  if (getClass() == CLASS_DEATH_KNIGHT)
1730  for (uint8 i = 0; i < MAX_RUNES; ++i)
1731  {
1732  // xinef: implement grace
1733  if (int32 cd = GetRuneCooldown(i))
1734  {
1735  SetRuneCooldown(i, (cd > m_regenTimer) ? cd - m_regenTimer : 0);
1736  // start grace counter, player must be in combat and rune has to go off cooldown
1737  if (IsInCombat() && cd <= m_regenTimer)
1738  SetGracePeriod(i, m_regenTimer - cd + 1); // added 1 because m_regenTimer-cd can be equal 0
1739  }
1740  // xinef: if grace is started, increase it but no more than cap
1741  else if (uint32 grace = GetGracePeriod(i))
1742  {
1743  if (grace < RUNE_GRACE_PERIOD)
1744  SetGracePeriod(i, std::min<uint32>(grace + m_regenTimer, RUNE_GRACE_PERIOD));
1745  }
1746  }
1747 
1748  if (m_regenTimerCount >= 2000)
1749  {
1750  // Not in combat or they have regeneration
1751  if (!IsInCombat() || IsPolymorphed() || m_baseHealthRegen ||
1754  {
1755  RegenerateHealth();
1756  }
1757 
1759  if (getClass() == CLASS_DEATH_KNIGHT)
1761 
1762  m_regenTimerCount -= 2000;
1763  }
1764 
1765  m_regenTimer = 0;
1766 
1767  // Handles the emotes for drinking and eating.
1768  // According to sniffs there is a background timer going on that repeats independed from the time window where the aura applies.
1769  // That's why we dont need to reset the timer on apply. In sniffs I have seen that the first call for the spell visual is totally random, then after
1770  // 5 seconds over and over again which confirms my theory that we have a independed timer.
1771  if (m_foodEmoteTimerCount >= 5000)
1772  {
1773  std::vector<AuraEffect*> auraList;
1775  AuraEffectList const& ModPowerRegenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN);
1776 
1777  auraList.reserve(ModRegenAuras.size() + ModPowerRegenAuras.size());
1778  auraList.insert(auraList.end(), ModRegenAuras.begin(), ModRegenAuras.end());
1779  auraList.insert(auraList.end(), ModPowerRegenAuras.begin(), ModPowerRegenAuras.end());
1780 
1781  for (auto itr = auraList.begin(); itr != auraList.end(); ++itr)
1782  {
1783  // Food emote comes above drinking emote if we have to decide (mage regen food for example)
1784  if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_REGEN) && (*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
1785  {
1787  break;
1788  }
1789  else if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_POWER_REGEN) && (*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
1790  {
1792  break;
1793  }
1794  }
1795  m_foodEmoteTimerCount -= 5000;
1796  }
1797 }
1798 
1800 {
1801  uint32 maxValue = GetMaxPower(power);
1802  if (!maxValue)
1803  return;
1804 
1805  //If .cheat power is on always have the max power
1807  {
1808  if (m_regenTimerCount >= 2000)
1809  {
1810  //Set the value to 0 first then set it to max to force resend of packet as for range clients keeps removing rage
1811  if (power == POWER_RAGE || power == POWER_RUNIC_POWER)
1812  {
1813  UpdateUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, 0);
1814  }
1815 
1816  SetPower(power, maxValue);
1817  return;
1818  }
1819  }
1820 
1821  uint32 curValue = GetPower(power);
1822 
1823  // TODO: possible use of miscvalueb instead of amount
1825  return;
1826 
1827  float addvalue = 0.0f;
1828 
1829  switch (power)
1830  {
1831  case POWER_MANA:
1832  {
1833  bool recentCast = IsUnderLastManaUseEffect();
1834  float ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA);
1835 
1836  if (getLevel() < 15)
1837  ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA) * (2.066f - (getLevel() * 0.066f));
1838 
1839  if (recentCast) // Trinity Updates Mana in intervals of 2s, which is correct
1840  addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer;
1841  else
1842  addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer;
1843  }
1844  break;
1845  case POWER_RAGE: // Regenerate rage
1846  {
1848  {
1849  float RageDecreaseRate = sWorld->getRate(RATE_POWER_RAGE_LOSS);
1850  addvalue += -20 * RageDecreaseRate; // 2 rage by tick (= 2 seconds => 1 rage/sec)
1851  }
1852  }
1853  break;
1854  case POWER_ENERGY: // Regenerate energy (rogue)
1855  addvalue += 0.01f * m_regenTimer * sWorld->getRate(RATE_POWER_ENERGY);
1856  break;
1857  case POWER_RUNIC_POWER:
1858  {
1860  {
1861  float RunicPowerDecreaseRate = sWorld->getRate(RATE_POWER_RUNICPOWER_LOSS);
1862  addvalue += -30 * RunicPowerDecreaseRate; // 3 RunicPower by tick
1863  }
1864  }
1865  break;
1866  case POWER_RUNE:
1867  case POWER_FOCUS:
1868  case POWER_HAPPINESS:
1869  break;
1870  case POWER_HEALTH:
1871  return;
1872  default:
1873  break;
1874  }
1875 
1876  // Mana regen calculated in Player::UpdateManaRegen()
1877  if (power != POWER_MANA)
1878  {
1880  for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
1881  if (Powers((*i)->GetMiscValue()) == power)
1882  AddPct(addvalue, (*i)->GetAmount());
1883 
1884  // Butchery requires combat for this effect
1885  if (power != POWER_RUNIC_POWER || IsInCombat())
1887  }
1888 
1889  if (addvalue < 0.0f)
1890  {
1891  if (curValue == 0)
1892  return;
1893  }
1894  else if (addvalue > 0.0f)
1895  {
1896  if (curValue == maxValue)
1897  return;
1898  }
1899  else
1900  return;
1901 
1902  addvalue += m_powerFraction[power];
1903  uint32 integerValue = uint32(fabs(addvalue));
1904 
1905  if (addvalue < 0.0f)
1906  {
1907  if (curValue > integerValue)
1908  {
1909  curValue -= integerValue;
1910  m_powerFraction[power] = addvalue + integerValue;
1911  }
1912  else
1913  {
1914  curValue = 0;
1915  m_powerFraction[power] = 0;
1916  }
1917  }
1918  else
1919  {
1920  curValue += integerValue;
1921 
1922  if (curValue > maxValue)
1923  {
1924  curValue = maxValue;
1925  m_powerFraction[power] = 0;
1926  }
1927  else
1928  m_powerFraction[power] = addvalue - integerValue;
1929  }
1930  if (m_regenTimerCount >= 2000)
1931  SetPower(power, curValue);
1932  else
1933  UpdateUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, curValue);
1934 }
1935 
1937 {
1938  uint32 curValue = GetHealth();
1939  uint32 maxValue = GetMaxHealth();
1940 
1941  if (curValue >= maxValue)
1942  return;
1943 
1944  float HealthIncreaseRate = sWorld->getRate(RATE_HEALTH);
1945 
1946  if (getLevel() < 15)
1947  HealthIncreaseRate = sWorld->getRate(RATE_HEALTH) * (2.066f - (getLevel() * 0.066f));
1948 
1949  float addvalue = 0.0f;
1950 
1951  // polymorphed case
1952  if (IsPolymorphed())
1953  addvalue = (float)GetMaxHealth() / 3;
1954  // normal regen case (maybe partly in combat case)
1956  {
1957  addvalue = OCTRegenHPPerSpirit() * HealthIncreaseRate;
1958  if (!IsInCombat())
1959  {
1961  for (AuraEffectList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i)
1962  AddPct(addvalue, (*i)->GetAmount());
1963 
1965  }
1968 
1969  if (!IsStandState())
1970  addvalue *= 1.5f;
1971  }
1972 
1973  // always regeneration bonus (including combat)
1975  addvalue += m_baseHealthRegen / 2.5f;
1976 
1977  if (addvalue < 0)
1978  addvalue = 0;
1979 
1980  ModifyHealth(int32(addvalue));
1981 }
1982 
1984 {
1986  switch (getPowerType())
1987  {
1988  case POWER_MANA:
1990  break;
1991  case POWER_RAGE:
1992  SetPower(POWER_RAGE, 0);
1993  break;
1994  case POWER_ENERGY:
1996  break;
1997  case POWER_RUNIC_POWER:
1999  break;
2000  default:
2001  break;
2002  }
2003 }
2004 
2006 {
2007  switch (questGiver->GetTypeId())
2008  {
2009  case TYPEID_UNIT:
2010  return GetNPCIfCanInteractWith(questGiver->GetGUID(), UNIT_NPC_FLAG_QUESTGIVER) != nullptr;
2011  case TYPEID_GAMEOBJECT:
2012  return GetGameObjectIfCanInteractWith(questGiver->GetGUID(), GAMEOBJECT_TYPE_QUESTGIVER) != nullptr;
2013  case TYPEID_PLAYER:
2014  return IsAlive() && questGiver->ToPlayer()->IsAlive();
2015  case TYPEID_ITEM:
2016  return IsAlive();
2017  default:
2018  break;
2019  }
2020  return false;
2021 }
2022 
2024 {
2025  // unit checks
2026  if (!guid)
2027  return nullptr;
2028 
2029  if (!IsInWorld())
2030  return nullptr;
2031 
2032  if (IsInFlight())
2033  return nullptr;
2034 
2035  // exist (we need look pets also for some interaction (quest/etc)
2036  Creature* creature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
2037  if (!creature)
2038  return nullptr;
2039 
2040  // Deathstate checks
2042  return nullptr;
2043 
2044  // alive or spirit healer
2045  if (!creature->IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_INTERACT_WHILE_DEAD))
2046  return nullptr;
2047 
2048  // appropriate npc type
2049  if (npcflagmask && !creature->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
2050  return nullptr;
2051 
2052  // not allow interaction under control, but allow with own pets
2053  if (creature->GetCharmerGUID())
2054  return nullptr;
2055 
2056  // xinef: perform better check
2057  if (creature->GetReactionTo(this) <= REP_UNFRIENDLY)
2058  return nullptr;
2059 
2060  // xinef: not needed, CORRECTLY checked above including forced reputations etc
2061  // not unfriendly
2062  //if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(creature->GetFaction()))
2063  // if (factionTemplate->faction)
2064  // if (FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction))
2065  // if (faction->reputationListID >= 0 && GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY)
2066  // return nullptr;
2067 
2068  // not too far
2069  if (!creature->IsWithinDistInMap(this, INTERACTION_DISTANCE))
2070  return nullptr;
2071 
2072  // pussywizard: many npcs have missing conditions for class training and rogue trainer can for eg. train dual wield to a shaman :/ too many to change in sql and watch in the future
2073  // pussywizard: this function is not used when talking, but when already taking action (buy spell, reset talents, show spell list)
2075  return nullptr;
2076 
2077  return creature;
2078 }
2079 
2081 {
2082  if (GameObject* go = GetMap()->GetGameObject(guid))
2083  {
2084  if (go->GetGoType() == type)
2085  {
2086  if (go->IsWithinDistInMap(this))
2087  {
2088  return go;
2089  }
2090 
2091  LOG_DEBUG("maps", "IsGameObjectOfTypeInRange: GameObject '%s' [%s] is too far away from player %s [%s] to be used by him (distance=%f, maximal 10 is allowed)",
2092  go->GetGOInfo()->name.c_str(), go->GetGUID().ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str(), go->GetDistance(this));
2093  }
2094  }
2095  return nullptr;
2096 }
2097 
2098 bool Player::IsFalling() const
2099 {
2100  // Xinef: Added !IsInFlight check
2101  return GetPositionZ() < m_lastFallZ && !IsInFlight();
2102 }
2103 
2105 {
2106  if (m_isInWater == apply)
2107  return;
2108 
2109  //define player in water by opcodes
2110  //move player's guid into HateOfflineList of those mobs
2111  //which can't swim and move guid back into ThreatList when
2112  //on surface.
2113  //TODO: exist also swimming mobs, and function must be symmetric to enter/leave water
2114  m_isInWater = apply;
2115 
2116  // remove auras that need water/land
2118 
2120 }
2121 
2122 bool Player::IsInAreaTriggerRadius(const AreaTrigger* trigger) const
2123 {
2124  static const float delta = 5.0f;
2125 
2126  if (!trigger || GetMapId() != trigger->map)
2127  return false;
2128 
2129  if (trigger->radius > 0)
2130  {
2131  // if we have radius check it
2132  float dist = GetDistance(trigger->x, trigger->y, trigger->z);
2133  if (dist > trigger->radius + delta)
2134  return false;
2135  }
2136  else
2137  {
2138  Position center(trigger->x, trigger->y, trigger->z, trigger->orientation);
2139  if (!IsWithinBox(center, trigger->length / 2 + delta, trigger->width / 2 + delta, trigger->height / 2 + delta))
2140  return false;
2141  }
2142 
2143  return true;
2144 }
2145 
2147 {
2148  if (on)
2149  {
2155 
2156  if (Pet* pet = GetPet())
2157  {
2159  pet->SetFaction(FACTION_FRIENDLY);
2160  pet->getHostileRefMgr().setOnlineOfflineState(false);
2161  }
2162 
2165 
2168 
2169  SetPhaseMask(uint32(PHASEMASK_ANYWHERE), false); // see and visible in all phases
2171  }
2172  else
2173  {
2174  // restore phase
2175  uint32 newPhase = GetPhaseByAuras();
2176 
2177  if (!newPhase)
2178  newPhase = PHASEMASK_NORMAL;
2179 
2180  SetPhaseMask(newPhase, false);
2181 
2183  SetFactionForRace(getRace(true));
2186 
2187  if (Pet* pet = GetPet())
2188  {
2189  pet->SetFaction(GetFaction());
2190  pet->getHostileRefMgr().setOnlineOfflineState(true);
2191  }
2192 
2193  // restore FFA PvP Server state
2194  if (sWorld->IsFFAPvPRealm())
2196 
2197  // restore FFA PvP area state, remove not allowed for GM mounts
2199 
2202  }
2203 
2205 }
2206 
2208 {
2209  const uint32 VISUAL_AURA = 37800;
2210 
2211  if (on)
2212  {
2213  if (HasAura(VISUAL_AURA))
2214  RemoveAurasDueToSpell(VISUAL_AURA);
2215 
2216  m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag
2218  }
2219  else
2220  {
2221  AddAura(VISUAL_AURA, this);
2222 
2224 
2225  SetAcceptWhispers(false);
2226  SetGameMaster(true);
2227 
2229  }
2230 }
2231 
2232 bool Player::IsGroupVisibleFor(Player const* p) const
2233 {
2234  switch (sWorld->getIntConfig(CONFIG_GROUP_VISIBILITY))
2235  {
2236  default:
2237  return IsInSameGroupWith(p);
2238  case 1:
2239  return IsInSameRaidWith(p);
2240  case 2:
2241  return GetTeamId() == p->GetTeamId();
2242  }
2243 }
2244 
2245 bool Player::IsInSameGroupWith(Player const* p) const
2246 {
2247  return p == this || (GetGroup() != nullptr &&
2248  GetGroup() == p->GetGroup() &&
2249  GetGroup()->SameSubGroup(this, p));
2250 }
2251 
2255 {
2256  Group* group = GetGroupInvite();
2257  if (!group)
2258  return;
2259 
2260  group->RemoveInvite(this);
2261 
2262  if (group->GetMembersCount() <= 1) // group has just 1 member => disband
2263  {
2264  if (group->IsCreated())
2265  {
2266  group->Disband(true);
2267  group = nullptr; // gets deleted in disband
2268  }
2269  else
2270  {
2271  group->RemoveAllInvites();
2272  delete group;
2273  group = nullptr;
2274  }
2275  }
2276 }
2277 
2278 void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /* = ObjectGuid::Empty */, const char* reason /* = nullptr */)
2279 {
2280  if (group)
2281  {
2282  group->RemoveMember(guid, method, kicker, reason);
2283  group = nullptr;
2284  }
2285 }
2286 
2287 void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend, float /*group_rate*/)
2288 {
2289  WorldPacket data(SMSG_LOG_XPGAIN, 22); // guess size?
2290  data << (victim ? victim->GetGUID() : ObjectGuid::Empty); // guid
2291  data << uint32(GivenXP + BonusXP); // given experience
2292  data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type
2293 
2294  if (victim)
2295  {
2296  data << uint32(GivenXP); // experience without bonus
2297 
2298  // should use group_rate here but can't figure out how
2299  data << float(1); // 1 - none 0 - 100% group bonus output
2300  }
2301 
2302  data << uint8(recruitAFriend ? 1 : 0); // does the GivenXP include a RaF bonus?
2303  GetSession()->SendPacket(&data);
2304 }
2305 
2306 void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
2307 {
2308  if (xp < 1)
2309  return;
2310 
2311  if (!IsAlive() && !GetBattlegroundId())
2312  return;
2313 
2315  return;
2316 
2317  if (victim && victim->GetTypeId() == TYPEID_UNIT && !victim->ToCreature()->hasLootRecipient())
2318  return;
2319 
2320  uint8 level = getLevel();
2321 
2322  sScriptMgr->OnGivePlayerXP(this, xp, victim);
2323 
2324  // Favored experience increase START
2325  uint32 zone = GetZoneId();
2326  float favored_exp_mult = 0;
2327  if ((zone == 3483 || zone == 3562 || zone == 3836 || zone == 3713 || zone == 3714) && (HasAura(32096) || HasAura(32098)))
2328  favored_exp_mult = 0.05f; // Thrallmar's Favor and Honor Hold's Favor
2329 
2330  xp = uint32(xp * (1 + favored_exp_mult));
2331  // Favored experience increase END
2332 
2333  // XP to money conversion processed in Player::RewardQuest
2334  if (level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
2335  return;
2336 
2337  uint32 bonus_xp = 0;
2338  bool recruitAFriend = GetsRecruitAFriendBonus(true);
2339 
2340  // RaF does NOT stack with rested experience
2341  if (recruitAFriend)
2342  bonus_xp = 2 * xp; // xp + bonus_xp must add up to 3 * xp for RaF; calculation for quests done client-side
2343  else
2344  bonus_xp = victim ? GetXPRestBonus(xp) : 0; // XP resting bonus
2345 
2346  // hooks and multipliers can modify the xp with a zero or negative value
2347  // check again before sending invalid xp to the client
2348  if (xp < 1)
2349  {
2350  return;
2351  }
2352 
2353  SendLogXPGain(xp, victim, bonus_xp, recruitAFriend, group_rate);
2354 
2355  uint32 curXP = GetUInt32Value(PLAYER_XP);
2357  uint32 newXP = curXP + xp + bonus_xp;
2358 
2359  while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
2360  {
2361  newXP -= nextLvlXP;
2362 
2363  if (level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
2364  GiveLevel(level + 1);
2365 
2366  level = getLevel();
2367  nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
2368  }
2369 
2370  SetUInt32Value(PLAYER_XP, newXP);
2371 }
2372 
2373 // Update player to next level
2374 // Current player experience not update (must be update by caller)
2376 {
2377  uint8 oldLevel = getLevel();
2378  if (level == oldLevel)
2379  return;
2380 
2381  if (Guild* guild = GetGuild())
2382  guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level);
2383 
2384  PlayerLevelInfo info;
2385  sObjectMgr->GetPlayerLevelInfo(getRace(true), getClass(), level, &info);
2386 
2387  PlayerClassLevelInfo classInfo;
2388  sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
2389 
2390  // send levelup info to client
2391  WorldPacket data(SMSG_LEVELUP_INFO, (4 + 4 + MAX_POWERS * 4 + MAX_STATS * 4));
2392  data << uint32(level);
2393  data << uint32(int32(classInfo.basehealth) - int32(GetCreateHealth()));
2394  // for (int i = 0; i < MAX_POWERS; ++i) // Powers loop (0-6)
2395  data << uint32(int32(classInfo.basemana) - int32(GetCreateMana()));
2396  data << uint32(0);
2397  data << uint32(0);
2398  data << uint32(0);
2399  data << uint32(0);
2400  data << uint32(0);
2401  data << uint32(0);
2402  // end for
2403  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4)
2404  data << uint32(int32(info.stats[i]) - GetCreateStat(Stats(i)));
2405 
2406  GetSession()->SendPacket(&data);
2407 
2408  SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(level));
2409 
2410  //update level, max level of skills
2411  m_Played_time[PLAYED_TIME_LEVEL] = 0; // Level Played Time reset
2412 
2414 
2415  SetLevel(level);
2416 
2418 
2419  // save base values (bonuses already included in stored stats
2420  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
2421  SetCreateStat(Stats(i), info.stats[i]);
2422 
2423  SetCreateHealth(classInfo.basehealth);
2424  SetCreateMana(classInfo.basemana);
2425 
2429 
2430  UpdateAllStats();
2431 
2432  if (sWorld->getBoolConfig(CONFIG_ALWAYS_MAXSKILL)) // Max weapon skill when leveling up
2434 
2436 
2437  // set current level health and mana/energy to maximum after applying all mods.
2438  SetFullHealth();
2443  SetPower(POWER_FOCUS, 0);
2445 
2446  // update level to hunter/summon pet
2447  if (Pet* pet = GetPet())
2448  pet->SynchronizeLevelWithOwner();
2449 
2450  MailLevelReward const* mailReward = sObjectMgr->GetMailLevelReward(level, getRaceMask());
2451  if (mailReward && sScriptMgr->CanGiveMailRewardAtGiveLevel(this, level))
2452  {
2453  //- TODO: Poor design of mail system
2454  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2455  MailDraft(mailReward->mailTemplateId).SendMailTo(trans, this, MailSender(MAIL_CREATURE, mailReward->senderEntry));
2456  CharacterDatabase.CommitTransaction(trans);
2457  }
2458 
2460 
2461  // Refer-A-Friend
2462  if (GetSession()->GetRecruiterId())
2463  if (level < sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
2464  if (level % 2 == 0)
2465  {
2467 
2468  if (!HasByteFlag(PLAYER_FIELD_BYTES, 1, 0x01))
2469  SetByteFlag(PLAYER_FIELD_BYTES, 1, 0x01);
2470  }
2471 
2473 
2474  sScriptMgr->OnPlayerLevelChanged(this, oldLevel);
2475 }
2476 
2478 {
2479  uint32 talentPointsForLevel = CalculateTalentsPoints();
2480 
2481  // xinef: more talent points that we have are used, reset
2482  if (m_usedTalentCount > talentPointsForLevel)
2483  resetTalents(true);
2484  // xinef: else, recalculate free talent points count
2485  else
2486  SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount);
2487 
2488  if (!GetSession()->PlayerLoading())
2489  SendTalentsInfoData(false); // update at client
2490 }
2491 
2492 void Player::InitStatsForLevel(bool reapplyMods)
2493 {
2494  if (reapplyMods) //reapply stats values only on .reset stats (level) command
2496 
2497  PlayerClassLevelInfo classInfo;
2498  sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo);
2499 
2500  PlayerLevelInfo info;
2501  sObjectMgr->GetPlayerLevelInfo(getRace(true), getClass(), getLevel(), &info);
2502 
2505 
2506  // reset before any aura state sources (health set/aura apply)
2508 
2510 
2511  // set default cast time multiplier
2513 
2514  // reset size before reapply auras
2515  SetObjectScale(1.0f);
2516 
2517  // save base values (bonuses already included in stored stats
2518  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
2519  SetCreateStat(Stats(i), info.stats[i]);
2520 
2521  for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
2522  SetStat(Stats(i), info.stats[i]);
2523 
2524  SetCreateHealth(classInfo.basehealth);
2525 
2526  //set create powers
2527  SetCreateMana(classInfo.basemana);
2528 
2530 
2531  InitStatBuffMods();
2532 
2533  //reset rating fields values
2535  SetUInt32Value(index, 0);
2536 
2538  for (uint8 i = 0; i < 7; ++i)
2539  {
2543  }
2544 
2545  //reset attack power, damage and attack speed fields
2547  SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f); // offhand attack time
2549 
2556 
2563 
2564  // Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
2568 
2569  // Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
2570  for (uint8 i = 0; i < 7; ++i)
2572 
2576 
2577  // Dodge percentage
2579 
2580  // set armor (resistance 0) to original value (create_agility*2)
2582  SetResistanceBuffMods(SpellSchools(0), true, 0.0f);
2583  SetResistanceBuffMods(SpellSchools(0), false, 0.0f);
2584  // set other resistance to original value (0)
2585  for (uint8 i = 1; i < MAX_SPELL_SCHOOL; ++i)
2586  {
2587  SetResistance(SpellSchools(i), 0);
2588  SetResistanceBuffMods(SpellSchools(i), true, 0.0f);
2589  SetResistanceBuffMods(SpellSchools(i), false, 0.0f);
2590  }
2591 
2594  for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
2595  {
2598  }
2599  // Reset no reagent cost field
2600  for (uint8 i = 0; i < 3; ++i)
2602  // Init data for form but skip reapply item mods for form
2603  InitDataForForm(reapplyMods);
2604 
2605  // save new stats
2606  for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
2608 
2609  SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
2610 
2611  // cleanup mounted state (it will set correctly at aura loading if player saved at mount.
2613 
2614  // cleanup unit flags (will be re-applied if need at aura load).
2623 
2625 
2626  // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example.
2628 
2629  RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
2631 
2632  // restore if need some important flags
2633  SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
2634 
2635  if (reapplyMods) // reapply stats values only on .reset stats (level) command
2637 
2638  // set current level health and mana/energy to maximum after applying all mods.
2639  SetFullHealth();
2644  SetPower(POWER_FOCUS, 0);
2647 
2648  // update level to hunter/summon pet
2649  if (Pet* pet = GetPet())
2650  pet->SynchronizeLevelWithOwner();
2651 }
2652 
2654 {
2655  uint32 curTime = World::GetGameTimeMS();
2657 
2658  uint16 spellCount = 0;
2659 
2660  WorldPacket data(SMSG_INITIAL_SPELLS, (1 + 2 + 4 * m_spells.size() + 2 + m_spellCooldowns.size() * (4 + 2 + 2 + 4 + 4)));
2661  data << uint8(0);
2662 
2663  size_t countPos = data.wpos();
2664  data << uint16(spellCount); // spell count placeholder
2665 
2666  for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
2667  {
2668  if (itr->second->State == PLAYERSPELL_REMOVED)
2669  continue;
2670 
2671  if (!itr->second->Active || !itr->second->IsInSpec(GetActiveSpec()))
2672  continue;
2673 
2674  data << uint32(itr->first);
2675  data << uint16(0); // it's not slot id
2676 
2677  ++spellCount;
2678  }
2679 
2680  // Added spells from glyphs too (needed by spell tooltips)
2681  for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
2682  {
2683  if (uint32 glyph = GetGlyph(i))
2684  {
2685  if (GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyph))
2686  {
2687  data << uint32(glyphEntry->SpellId);
2688  data << uint16(0); // it's not slot id
2689 
2690  ++spellCount;
2691  }
2692  }
2693  }
2694 
2695  // xinef: we have to send talents, but not those on m_spells list
2696  for (PlayerTalentMap::iterator itr = m_talents.begin(); itr != m_talents.end(); ++itr)
2697  {
2698  if (itr->second->State == PLAYERSPELL_REMOVED)
2699  continue;
2700 
2701  // xinef: remove all active talent auras
2702  if (!(itr->second->specMask & GetActiveSpecMask()))
2703  continue;
2704 
2705  // xinef: already sent from m_spells
2706  if (itr->second->inSpellBook)
2707  continue;
2708 
2709  data << uint32(itr->first);
2710  data << uint16(0); // it's not slot id
2711 
2712  ++spellCount;
2713  }
2714 
2715  data.put<uint16>(countPos, spellCount); // write real count value
2716 
2717  uint16 spellCooldowns = m_spellCooldowns.size();
2718  data << uint16(spellCooldowns);
2719  for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr)
2720  {
2721  if (!itr->second.needSendToClient)
2722  continue;
2723 
2724  SpellInfo const* sEntry = sSpellMgr->GetSpellInfo(itr->first);
2725  if (!sEntry)
2726  continue;
2727 
2728  data << uint32(itr->first);
2729 
2730  data << uint16(itr->second.itemid); // cast item id
2731  data << uint16(itr->second.category); // spell category
2732 
2733  // send infinity cooldown in special format
2734  if (itr->second.end >= infTime)
2735  {
2736  data << uint32(1); // cooldown
2737  data << uint32(0x80000000); // category cooldown
2738  continue;
2739  }
2740 
2741  uint32 cooldown = itr->second.end > curTime ? itr->second.end - curTime : 0;
2742  data << uint32(itr->second.category ? 0 : cooldown); // cooldown
2743  data << uint32(itr->second.category ? cooldown : 0); // category cooldown
2744  }
2745 
2746  GetSession()->SendPacket(&data);
2747 }
2748 
2750 {
2751  for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
2752  {
2753  if ((*itr)->messageID == id)
2754  {
2755  //do not delete item, because Player::removeMail() is called when returning mail to sender.
2756  m_mail.erase(itr);
2757  return;
2758  }
2759  }
2760 }
2761 
2762 void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count)
2763 {
2764  WorldPacket data(SMSG_SEND_MAIL_RESULT, (4 + 4 + 4 + (mailError == MAIL_ERR_EQUIP_ERROR ? 4 : (mailAction == MAIL_ITEM_TAKEN ? 4 + 4 : 0))));
2765  data << (uint32) mailId;
2766  data << (uint32) mailAction;
2767  data << (uint32) mailError;
2768  if (mailError == MAIL_ERR_EQUIP_ERROR)
2769  data << (uint32) equipError;
2770  else if (mailAction == MAIL_ITEM_TAKEN)
2771  {
2772  data << (uint32) item_guid; // item guid low?
2773  data << (uint32) item_count; // item count?
2774  }
2775  GetSession()->SendPacket(&data);
2776 }
2777 
2779 {
2780  // deliver undelivered mail
2782  data << (uint32) 0;
2783  GetSession()->SendPacket(&data);
2784 }
2785 
2786 void Player::AddNewMailDeliverTime(time_t deliver_time)
2787 {
2788  sWorld->UpdateGlobalPlayerMails(GetGUID().GetCounter(), GetMailSize(), false);
2789 
2790  if (deliver_time <= time(nullptr)) // ready now
2791  {
2792  ++unReadMails;
2793  SendNewMail();
2794  }
2795  else // not ready and no have ready mails
2796  {
2797  if (!m_nextMailDelivereTime || m_nextMailDelivereTime > deliver_time)
2798  m_nextMailDelivereTime = deliver_time;
2799  }
2800 }
2801 
2802 bool Player::addTalent(uint32 spellId, uint8 addSpecMask, uint8 oldTalentRank)
2803 {
2804  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2805  if (!SpellMgr::CheckSpellValid(spellInfo, spellId, true))
2806  return false;
2807 
2808  TalentSpellPos const* talentPos = GetTalentSpellPos(spellId);
2809  if (!talentPos)
2810  return false;
2811 
2812  TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id);
2813  if (!talentInfo)
2814  return false;
2815 
2816  // xinef: remove old talent rank if any
2817  if (oldTalentRank)
2818  {
2819  _removeTalent(talentInfo->RankID[oldTalentRank - 1], addSpecMask);
2820  _removeTalentAurasAndSpells(talentInfo->RankID[oldTalentRank - 1]);
2821  SendLearnPacket(talentInfo->RankID[oldTalentRank - 1], false);
2822  }
2823 
2824  // xinef: add talent auras and spells
2825  if (GetActiveSpecMask() & addSpecMask)
2826  _addTalentAurasAndSpells(spellId);
2827 
2828  // xinef: find the spell on our talent map
2829  PlayerTalentMap::iterator itr = m_talents.find(spellId);
2830 
2831  // xinef: we do not have such a spell on our talent map
2832  if (itr == m_talents.end())
2833  {
2835  PlayerTalent* newTalent = new PlayerTalent();
2836  newTalent->State = state;
2837  newTalent->specMask = addSpecMask;
2838  newTalent->talentID = talentInfo->TalentID;
2839  newTalent->inSpellBook = talentInfo->addToSpellBook && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL);
2840 
2841  m_talents[spellId] = newTalent;
2842  return true;
2843  }
2844  // xinef: if current mask does not cover addMask, add it to iterator and save changes to DB
2845  else if (!(itr->second->specMask & addSpecMask))
2846  {
2847  itr->second->specMask |= addSpecMask;
2848  if (itr->second->State != PLAYERSPELL_NEW)
2849  itr->second->State = PLAYERSPELL_CHANGED;
2850 
2851  return true;
2852  }
2853 
2854  return false;
2855 }
2856 
2857 void Player::_removeTalent(uint32 spellId, uint8 specMask)
2858 {
2859  PlayerTalentMap::iterator itr = m_talents.find(spellId);
2860  if (itr == m_talents.end() || itr->second->State == PLAYERSPELL_REMOVED)
2861  return;
2862 
2863  _removeTalent(itr, specMask);
2864 }
2865 
2866 void Player::_removeTalent(PlayerTalentMap::iterator& itr, uint8 specMask)
2867 {
2868  // xinef: remove spec mask from iterator
2869  itr->second->specMask &= ~specMask;
2870 
2871  // xinef: if talent is not present in any spec - remove
2872  if (itr->second->specMask == 0)
2873  {
2874  if (itr->second->State == PLAYERSPELL_NEW)
2875  {
2876  delete itr->second;
2877  m_talents.erase(itr);
2878  return;
2879  }
2880  else
2881  itr->second->State = PLAYERSPELL_REMOVED;
2882  }
2883  // xinef: otherwise save changes to DB
2884  else if (itr->second->State != PLAYERSPELL_NEW)
2885  itr->second->State = PLAYERSPELL_CHANGED;
2886 }
2887 
2889 {
2890  RemoveOwnedAura(spellId);
2891 
2892  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2893  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2894  {
2895  // pussywizard: remove pet auras
2896  if (PetAura const* petSpell = sSpellMgr->GetPetAura(spellId, i))
2897  RemovePetAura(petSpell);
2898 
2899  // pussywizard: remove all triggered auras
2900  if (spellInfo->Effects[i].TriggerSpell > 0)
2901  RemoveAurasDueToSpell(spellInfo->Effects[i].TriggerSpell);
2902 
2903  // xinef: remove temporary spells added by talent
2904  // xinef: recursively remove all learnt spells
2905  if (spellInfo->Effects[i].TriggerSpell > 0 && spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
2906  {
2907  removeSpell(spellInfo->Effects[i].TriggerSpell, SPEC_MASK_ALL, true);
2908  _removeTalentAurasAndSpells(spellInfo->Effects[i].TriggerSpell);
2909  }
2910  }
2911 }
2912 
2914 {
2915  // pussywizard: spells learnt from talents are added as TEMPORARY, so not saved to db (only the talent itself is saved)
2916  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2917  if (spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
2918  {
2919  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2920  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL && !sSpellMgr->IsAdditionalTalentSpell(spellInfo->Effects[i].TriggerSpell))
2921  _addSpell(spellInfo->Effects[i].TriggerSpell, SPEC_MASK_ALL, true);
2922  }
2923  else if (spellInfo->IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
2924  {
2925  if (IsNeedCastPassiveSpellAtLearn(spellInfo))
2926  CastSpell(this, spellId, true);
2927  }
2928 }
2929 
2930 void Player::SendLearnPacket(uint32 spellId, bool learn)
2931 {
2932  if (learn)
2933  {
2935  data << uint32(spellId);
2936  data << uint16(0);
2937  GetSession()->SendPacket(&data);
2938  }
2939  else
2940  {
2942  data << uint32(spellId);
2943  GetSession()->SendPacket(&data);
2944  }
2945 }
2946 
2947 bool Player::addSpell(uint32 spellId, uint8 addSpecMask, bool updateActive, bool temporary /*= false*/, bool learnFromSkill /*= false*/)
2948 {
2949  if (!_addSpell(spellId, addSpecMask, temporary, learnFromSkill))
2950  return false;
2951 
2952  if (!updateActive)
2953  return true;
2954 
2955  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); // must exist, checked in _addSpell
2956 
2957  // pussywizard: now update active state for all ranks of this spell! and send packet to swap on action bar
2958  // pussywizard: assumption - it's in all specs, can't be a talent
2959  if (!spellInfo->IsStackableWithRanks() && spellInfo->IsRanked())
2960  {
2961  SpellInfo const* nextSpellInfo = sSpellMgr->GetSpellInfo(sSpellMgr->GetFirstSpellInChain(spellInfo->Id));
2962  while (nextSpellInfo)
2963  {
2964  PlayerSpellMap::iterator itr = m_spells.find(nextSpellInfo->Id);
2965  if (itr != m_spells.end() && itr->second->State != PLAYERSPELL_REMOVED && itr->second->Active)
2966  {
2967  if (nextSpellInfo->GetRank() < spellInfo->GetRank())
2968  {
2969  itr->second->Active = false;
2970  if (IsInWorld())
2971  {
2972  WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4);
2973  data << uint32(nextSpellInfo->Id);
2974  data << uint32(spellInfo->Id);
2975  GetSession()->SendPacket(&data);
2976  }
2977  return false;
2978  }
2979  else if (nextSpellInfo->GetRank() > spellInfo->GetRank())
2980  {
2981  PlayerSpellMap::iterator itr2 = m_spells.find(spellInfo->Id);
2982  if (itr2 != m_spells.end())
2983  itr2->second->Active = false;
2984  return false;
2985  }
2986  }
2987  nextSpellInfo = nextSpellInfo->GetNextRankSpell();
2988  }
2989  }
2990 
2991  return true;
2992 }
2993 
2994 bool Player::_addSpell(uint32 spellId, uint8 addSpecMask, bool temporary, bool learnFromSkill /*= false*/)
2995 {
2996  // pussywizard: this can be called to OVERWRITE currently existing spell params! usually to set active = false for lower ranks of a spell
2997 
2998  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2999  if (!SpellMgr::CheckSpellValid(spellInfo, spellId, false))
3000  return false;
3001 
3002  // pussywizard: already found and temporary, nothing to do
3003  PlayerSpellMap::iterator itr = m_spells.find(spellId);
3004  if (itr != m_spells.end() && itr->second->State == PLAYERSPELL_TEMPORARY)
3005  return false;
3006 
3007  // xinef: send packet so client can properly recognize this new spell
3008  // xinef: ignore passive spells and spells with learn effect
3009  // xinef: send spells with no aura effects (ie dual wield)
3010  if (IsInWorld() && !isBeingLoaded() && temporary && !learnFromSkill && (!spellInfo->HasAttribute(SpellAttr0(SPELL_ATTR0_PASSIVE | SPELL_ATTR0_DO_NOT_DISPLAY)) || !spellInfo->HasAnyAura()) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
3011  SendLearnPacket(spellInfo->Id, true);
3012 
3013  // xinef: DO NOT allow to learn spell with effect learn spell!
3014  // xinef: if spell possess spell learn effects only, learn those spells as temporary (eg. Metamorphosis, Tree of Life)
3015  if (temporary && spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
3016  {
3017  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3018  if (spellInfo->Effects[i].IsEffect())
3019  {
3020  if (spellInfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
3021  {
3022  LOG_INFO("entities.player", "TRYING TO LEARN SPELL WITH EFFECT LEARN: %u, PLAYER: %s", spellId, GetGUID().ToString().c_str());
3023  return false;
3024  //ABORT();
3025  }
3026  else if (const SpellInfo* learnSpell = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell))
3027  _addSpell(learnSpell->Id, SPEC_MASK_ALL, true);
3028  }
3029 
3030  return false;
3031  }
3032 
3033  if (itr != m_spells.end()) // pussywizard: already know this spell, so update information
3034  {
3035  // pussywizard: do nothing if already set as wanted
3036  if (itr->second->State != PLAYERSPELL_REMOVED && (itr->second->specMask & addSpecMask) == addSpecMask)
3037  return false;
3038 
3039  // pussywizard: need cast auras, learn linked spells, do professions stuff, etc.
3040  // pussywizard: but only for spells that are really added (inactive -> active OR added to current spec)
3041  bool spellIsNew = true;
3042 
3043  // pussywizard: present in m_spells, not removed, already in current spec, already active
3044  if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(m_activeSpec))
3045  spellIsNew = false;
3046 
3047  // pussywizard: update info in m_spells
3048  if (itr->second->State != PLAYERSPELL_NEW && (itr->second->specMask & addSpecMask) != addSpecMask)
3049  itr->second->State = PLAYERSPELL_CHANGED;
3050  itr->second->Active = true;
3051  itr->second->specMask |= addSpecMask;
3052 
3053  if (!spellIsNew)
3054  return true;
3055  }
3056  else // pussywizard: not found in m_spells
3057  {
3058  PlayerSpell* newspell = new PlayerSpell;
3059  newspell->Active = true;
3061  newspell->specMask = addSpecMask;
3062 
3063  m_spells[spellId] = newspell;
3064  }
3065 
3066  // pussywizard: return if spell not in current spec
3067  // pussywizard: return true to fix active for ranks, this condition is true only at loading, so no problems with learning packets
3068  if (!((1 << GetActiveSpec()) & addSpecMask))
3069  return true;
3070 
3071  // xinef: do not add spells with effect learn spell
3072  if (spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
3073  {
3074  LOG_INFO("entities.player", "TRYING TO LEARN SPELL WITH EFFECT LEARN 2: %u, PLAYER: %s", spellId, GetGUID().ToString().c_str());
3075  m_spells.erase(spellInfo->Id); // mem leak, but should never happen
3076  return false;
3077  //ABORT();
3078  }
3079  // pussywizard: cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks
3080  else if (spellInfo->IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
3081  {
3082  if (IsNeedCastPassiveSpellAtLearn(spellInfo))
3083  CastSpell(this, spellId, true);
3084  }
3085  // pussywizard: cast and return, learnt spells will update profession count, etc.
3086  else if (spellInfo->HasEffect(SPELL_EFFECT_SKILL_STEP))
3087  {
3088  CastSpell(this, spellId, true);
3089  return false;
3090  }
3091 
3092  // xinef: unapply aura stats if dont meet requirements
3093  // xinef: handle only if player is not loaded, loading is handled in loadfromdb
3094  if (!isBeingLoaded())
3095  if (Aura* aura = GetAura(spellId))
3096  {
3097  if (aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_35_PERCENT ||
3098  aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTH_ABOVE_75_PERCENT ||
3099  aura->GetSpellInfo()->CasterAuraState == AURA_STATE_HEALTHLESS_20_PERCENT )
3100  if (!HasAuraState((AuraStateType)aura->GetSpellInfo()->CasterAuraState))
3101  aura->HandleAllEffects(aura->GetApplicationOfTarget(GetGUID()), AURA_EFFECT_HANDLE_REAL, false);
3102  }
3103 
3104  // pussywizard: update free primary prof points
3105  if (uint32 freeProfs = GetFreePrimaryProfessionPoints())
3106  {
3107  if (spellInfo->IsPrimaryProfessionFirstRank())
3108  SetFreePrimaryProfessions(freeProfs - 1);
3109  }
3110 
3111  uint16 maxskill = GetMaxSkillValueForLevel();
3112  SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId);
3113  SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId);
3114  // xinef: set appropriate skill value
3115  if (spellLearnSkill)
3116  {
3117  uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill);
3118  uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill);
3119  uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? maxskill : spellLearnSkill->maxvalue;
3120 
3121  if (skill_value < spellLearnSkill->value)
3122  skill_value = spellLearnSkill->value;
3123  if (skill_max_value < new_skill_max_value)
3124  skill_max_value = new_skill_max_value;
3125 
3126  SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
3127  }
3128  else
3129  {
3130  // not ranked skills
3131  for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
3132  {
3133  SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->SkillLine);
3134  if (!pSkill)
3135  {
3136  continue;
3137  }
3138 
3139  // @todo confirm if rogues start wth lockpicking skill at level 1 but only recieve the spell to use it at level 16
3140  // Added for runeforging, it is confirmed via sniff that this happens when death knights learn the spell, not on character creation.
3141  if ((_spell_idx->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->TrivialSkillLineRankHigh == 0))
3142  {
3143  LearnDefaultSkill(pSkill->id, 0);
3144  }
3145 
3146  if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
3147  {
3148  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3149  {
3150  if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && spellInfo->Effects[i].CalcValue() == 310)
3151  {
3152  SetHas310Flyer(true);
3153  }
3154  }
3155  }
3156  }
3157  }
3158 
3159  // xinef: update achievement criteria
3160  if (!GetSession()->PlayerLoading())
3161  {
3162  for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
3163  {
3166  }
3168  }
3169 
3170  return true;
3171 }
3172 
3174 {
3175  // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell
3176  // talent dependent passives activated at form apply have proper stance data
3178  return (!spellInfo->Stances || (form && (spellInfo->Stances & (1 << (form - 1)))) ||
3180 }
3181 
3182 void Player::learnSpell(uint32 spellId, bool temporary /*= false*/, bool learnFromSkill /*= false*/)
3183 {
3184  // Xinef: don't allow to learn active spell once more
3185  if (HasActiveSpell(spellId))
3186  {
3187  LOG_ERROR("entities.player", "Player (%s) tries to learn already active spell: %u", GetGUID().ToString().c_str(), spellId);
3188  return;
3189  }
3190 
3191  uint32 firstRankSpellId = sSpellMgr->GetFirstSpellInChain(spellId);
3192  bool thisSpec = GetTalentSpellCost(firstRankSpellId) > 0 || sSpellMgr->IsAdditionalTalentSpell(firstRankSpellId);
3193  bool added = addSpell(spellId, thisSpec ? GetActiveSpecMask() : SPEC_MASK_ALL, true, temporary, learnFromSkill);
3194  if (added)
3195  {
3196  sScriptMgr->OnPlayerLearnSpell(this, spellId);
3197 
3198  // pussywizard: a system message "you have learnt spell X (rank Y)"
3199  if (IsInWorld())
3200  SendLearnPacket(spellId, true);
3201  }
3202 
3203  // pussywizard: rank stuff at the end!
3204  if (uint32 nextSpell = sSpellMgr->GetNextSpellInChain(spellId))
3205  {
3206  // pussywizard: lookup next rank in m_spells (the only talents on m_spella are for example pyroblast, that have all ranks restored upon learning rank 1)
3207  // pussywizard: next ranks must not be in current spec (otherwise no need to learn already learnt)
3208  PlayerSpellMap::iterator itr = m_spells.find(nextSpell);
3209  if (itr != m_spells.end() && itr->second->State != PLAYERSPELL_REMOVED && !itr->second->IsInSpec(m_activeSpec))
3210  learnSpell(nextSpell, temporary);
3211  }
3212 
3213  // xinef: if we learn new spell, check all spells requiring this spell, if we have such a spell, and it is not in current spec - learn it
3214  SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(spellId);
3215  for (SpellsRequiringSpellMap::const_iterator itr = spellsRequiringSpell.first; itr != spellsRequiringSpell.second; ++itr)
3216  {
3217  PlayerSpellMap::iterator itr2 = m_spells.find(itr->second);
3218  if (itr2 != m_spells.end() && itr2->second->State != PLAYERSPELL_REMOVED && !itr2->second->IsInSpec(m_activeSpec))
3219  learnSpell(itr2->first, temporary);
3220  }
3221 }
3222 
3223 void Player::removeSpell(uint32 spell_id, uint8 removeSpecMask, bool onlyTemporary)
3224 {
3225  PlayerSpellMap::iterator itr = m_spells.find(spell_id);
3226  if (itr == m_spells.end())
3227  return;
3228 
3229  // pussywizard: nothing to do if already removed or not in specs of removeSpecMask
3230  if (itr->second->State == PLAYERSPELL_REMOVED || (itr->second->specMask & removeSpecMask) == 0)
3231  return;
3232 
3233  // pussywizard: avoid any possible bugs
3234  if (onlyTemporary && itr->second->State != PLAYERSPELL_TEMPORARY)
3235  return;
3236 
3237  // pussywizard: remove non-talent higher ranks (recursive)
3238  // pussywizard: do this at the beginning, not in the middle of removing!
3239  if (uint32 nextSpell = sSpellMgr->GetNextSpellInChain(spell_id))
3240  if (!GetTalentSpellPos(nextSpell))
3241  removeSpell(nextSpell, removeSpecMask, onlyTemporary);
3242 
3243  // xinef: if current spell has talentcost, remove spells requiring this spell
3244  uint32 firstRankSpellId = sSpellMgr->GetFirstSpellInChain(spell_id);
3245  if (GetTalentSpellCost(firstRankSpellId))
3246  {
3247  SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(firstRankSpellId);
3248  for (auto spellsItr = spellsRequiringSpell.first; spellsItr != spellsRequiringSpell.second; ++spellsItr)
3249  {
3250  removeSpell(spellsItr->second, removeSpecMask, onlyTemporary);
3251  }
3252  }
3253 
3254  // pussywizard: re-search, it can be corrupted in prev loop
3255  itr = m_spells.find(spell_id);
3256  if (itr == m_spells.end())
3257  return;
3258 
3259  itr->second->specMask = (((uint8)itr->second->specMask) & ~removeSpecMask); // pussywizard: update specMask in map
3260 
3261  // pussywizard: some more conditions needed for spells like pyroblast (shouldn't be fully removed when not available in any spec, should stay in db with specMask = 0)
3262  if (GetTalentSpellCost(firstRankSpellId) == 0 && !sSpellMgr->IsAdditionalTalentSpell(firstRankSpellId) && itr->second->specMask == 0)
3263  {
3264  if (itr->second->State == PLAYERSPELL_NEW || itr->second->State == PLAYERSPELL_TEMPORARY)
3265  {
3266  delete itr->second;
3267  m_spells.erase(itr);
3268  }
3269  else
3270  itr->second->State = PLAYERSPELL_REMOVED;
3271  }
3272  else if (itr->second->State != PLAYERSPELL_NEW && itr->second->State != PLAYERSPELL_TEMPORARY)
3273  itr->second->State = PLAYERSPELL_CHANGED;
3274 
3275  // xinef: this is used for talents and they are not removed in removeSpell function...
3276  // xinef: however ill leave this here just in case
3277  // pussywizard: remove owned aura obtained from currently removed spell
3278  RemoveOwnedAura(spell_id);
3279 
3280  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
3281  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3282  {
3283  // pussywizard: remove pet auras
3284  if (PetAura const* petSpell = sSpellMgr->GetPetAura(spell_id, i))
3285  RemovePetAura(petSpell);
3286 
3287  // pussywizard: remove all triggered auras
3288  if (spellInfo->Effects[i].TriggerSpell > 0)
3289  RemoveAurasDueToSpell(spellInfo->Effects[i].TriggerSpell);
3290  }
3291 
3292  // pussywizard: update free primary prof points
3293  if (spellInfo->IsPrimaryProfessionFirstRank())
3294  {
3295  uint32 freeProfs = GetFreePrimaryProfessionPoints() + 1;
3296  if (freeProfs <= sWorld->getIntConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL))
3297  SetFreePrimaryProfessions(freeProfs);
3298  }
3299 
3300  // pussywizard: update 310 flyer
3301  if (Has310Flyer(false))
3302  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3303  if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && spellInfo->Effects[i].CalcValue() == 310)
3304  Has310Flyer(true, spell_id);
3305 
3306  // pussywizard: remove dependent skill
3307  SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spell_id);
3308  if (spellLearnSkill)
3309  {
3310  uint32 prev_spell = sSpellMgr->GetPrevSpellInChain(spell_id);
3311 
3312  if (!prev_spell) // pussywizard: first rank, remove skill
3313  SetSkill(spellLearnSkill->skill, 0, 0, 0);
3314  else // pussywizard: search previous ranks
3315  {
3316  SpellLearnSkillNode const* prevSkill = sSpellMgr->GetSpellLearnSkill(prev_spell);
3317  while (!prevSkill && prev_spell)
3318  {
3319  prev_spell = sSpellMgr->GetPrevSpellInChain(prev_spell);
3320  prevSkill = sSpellMgr->GetSpellLearnSkill(sSpellMgr->GetFirstSpellInChain(prev_spell));
3321  }
3322 
3323  if (!prevSkill) // pussywizard: not found prev skill setting, remove skill
3324  SetSkill(spellLearnSkill->skill, 0, 0, 0);
3325  else // pussywizard: set to prev skill setting values
3326  {
3327  uint32 skill_value = GetPureSkillValue(prevSkill->skill);
3328  uint32 skill_max_value = GetPureMaxSkillValue(prevSkill->skill);
3329  uint32 new_skill_max_value = prevSkill->maxvalue == 0 ? GetMaxSkillValueForLevel() : prevSkill->maxvalue;
3330 
3331  if (skill_value > prevSkill->value)
3332  skill_value = prevSkill->value;
3333  if (skill_max_value > new_skill_max_value)
3334  skill_max_value = new_skill_max_value;
3335 
3336  SetSkill(prevSkill->skill, prevSkill->step, skill_value, skill_max_value);
3337  }
3338  }
3339  }
3340  else
3341  {
3342  SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spell_id);
3343  // most likely will never be used, haven't heard of cases where players unlearn a mount
3344  if (Has310Flyer(false) && spellInfo)
3345  {
3346  for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
3347  {
3348  SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->SkillLine);
3349  if (!pSkill)
3350  continue;
3351 
3352  if (_spell_idx->second->SkillLine == SKILL_MOUNTS)
3353  {
3354  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3355  {
3356  if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
3357  spellInfo->Effects[i].CalcValue() == 310)
3358  {
3359  Has310Flyer(true, spell_id); // with true as first argument its also used to set/remove the flag
3360  break;
3361  }
3362  }
3363  }
3364  }
3365  }
3366  }
3367 
3368  // pussywizard: remove from spell book (can't be replaced by previous rank, because such spells can't be unlearnt)
3369  if (!onlyTemporary || ((!spellInfo->HasAttribute(SpellAttr0(SPELL_ATTR0_PASSIVE | SPELL_ATTR0_DO_NOT_DISPLAY)) || !spellInfo->HasAnyAura()) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL)))
3370  {
3371  sScriptMgr->OnPlayerForgotSpell(this, spell_id);
3372  SendLearnPacket(spell_id, false);
3373  }
3374 }
3375 
3376 bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId)
3377 {
3378  if (!checkAllSpells)
3380  else
3381  {
3382  SetHas310Flyer(false);
3383  SpellInfo const* spellInfo;
3384  for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
3385  {
3386  // pussywizard:
3387  if (itr->second->State == PLAYERSPELL_REMOVED)
3388  continue;
3389 
3390  if (itr->first == excludeSpellId)
3391  continue;
3392 
3393  SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(itr->first);
3394  for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
3395  {
3396  if (_spell_idx->second->SkillLine != SKILL_MOUNTS)
3397  break; // We can break because mount spells belong only to one skillline (at least 310 flyers do)
3398 
3399  spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
3400  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3401  if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
3402  spellInfo->Effects[i].CalcValue() == 310)
3403  {
3404  SetHas310Flyer(true);
3405  return true;
3406  }
3407  }
3408  }
3409  }
3410 
3411  return false;
3412 }
3413 
3414 void Player::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */)
3415 {
3416  m_spellCooldowns.erase(spell_id);
3417 
3418  if (update)
3419  SendClearCooldown(spell_id, this);
3420 }
3421 
3423 {
3424  SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(cat);
3425  if (i_scstore != sSpellsByCategoryStore.end())
3426  for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
3427  RemoveSpellCooldown(i_scset->second, true);
3428 }
3429 
3430 void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
3431 {
3432  // remove cooldowns on spells that have < 10 min CD
3434  SpellCooldowns::iterator itr, next;
3435  for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next)
3436  {
3437  next = itr;
3438  ++next;
3439  SpellInfo const* spellInfo = sSpellMgr->CheckSpellInfo(itr->first);
3440  if (!spellInfo)
3441  {
3442  continue;
3443  }
3444 
3446  RemoveSpellCooldown(itr->first, true);
3447  else if (spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS && itr->second.end < infTime// xinef: dont remove active cooldowns - bugz
3448  && itr->second.maxduration < 10 * MINUTE * IN_MILLISECONDS) // xinef: dont clear cooldowns that have maxduration > 10 minutes (eg item cooldowns with no spell.dbc cooldown info)
3449  RemoveSpellCooldown(itr->first, true);
3450  }
3451 
3452  // pet cooldowns
3453  if (removeActivePetCooldowns)
3454  if (Pet* pet = GetPet())
3455  {
3456  // notify player
3457  for (CreatureSpellCooldowns::const_iterator itr2 = pet->m_CreatureSpellCooldowns.begin(); itr2 != pet->m_CreatureSpellCooldowns.end(); ++itr2)
3458  SendClearCooldown(itr2->first, pet);
3459 
3460  // actually clear cooldowns
3461  pet->m_CreatureSpellCooldowns.clear();
3462  }
3463 }
3464 
3466 {
3468  if (!m_spellCooldowns.empty())
3469  {
3470  for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr)
3471  if (itr->second.end < infTime)
3472  SendClearCooldown(itr->first, this);
3473 
3474  m_spellCooldowns.clear();
3475  }
3476 }
3477 
3479 {
3480  // some cooldowns can be already set at aura loading...
3481 
3482  //QueryResult* result = CharacterDatabase.PQuery("SELECT spell, category, item, time FROM character_spell_cooldown WHERE guid = '%u'", GetGUID().GetCounter()());
3483 
3484  if (result)
3485  {
3486  time_t curTime = time(nullptr);
3487 
3488  do
3489  {
3490  Field* fields = result->Fetch();
3491  uint32 spell_id = fields[0].GetUInt32();
3492  uint16 category = fields[1].GetUInt16();
3493  uint32 item_id = fields[2].GetUInt32();
3494  uint32 db_time = fields[3].GetUInt32();
3495  bool needSend = fields[4].GetBool();
3496 
3497  if (!sSpellMgr->GetSpellInfo(spell_id))
3498  {
3499  LOG_ERROR("entities.player", "Player %s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGUID().ToString().c_str(), spell_id);
3500  continue;
3501  }
3502 
3503  // skip outdated cooldown
3504  if (db_time <= curTime)
3505  continue;
3506 
3507  _AddSpellCooldown(spell_id, category, item_id, (db_time - curTime) * IN_MILLISECONDS, needSend);
3508 
3509  LOG_DEBUG("entities.player.loading", "Player (%s) spell %u, item %u cooldown loaded (%u secs).", GetGUID().ToString().c_str(), spell_id, item_id, uint32(db_time - curTime));
3510  } while (result->NextRow());
3511  }
3512 }
3513 
3515 {
3517  stmt->setUInt32(0, GetGUID().GetCounter());
3518  trans->Append(stmt);
3519 
3520  time_t curTime = time(nullptr);
3521  uint32 curMSTime = World::GetGameTimeMS();
3522  uint32 infTime = curMSTime + infinityCooldownDelayCheck;
3523 
3524  bool first_round = true;
3525  std::ostringstream ss;
3526 
3527  // remove outdated and save active
3528  for (SpellCooldowns::iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end();)
3529  {
3530  // Xinef: dummy cooldown for procs
3531  if (itr->first == uint32(-1))
3532  {
3533  ++itr;
3534  continue;
3535  }
3536 
3537  if (itr->second.end <= curMSTime + 1000)
3538  m_spellCooldowns.erase(itr++);
3539  else if (itr->second.end <= infTime && (logout || itr->second.end > (curMSTime + 5 * MINUTE * IN_MILLISECONDS))) // not save locked cooldowns, it will be reset or set at reload
3540  {
3541  if (first_round)
3542  {
3543  ss << "INSERT INTO character_spell_cooldown (guid, spell, category, item, time, needSend) VALUES ";
3544  first_round = false;
3545  }
3546  // next new/changed record prefix
3547  else
3548  ss << ',';
3549 
3550  uint64 cooldown = uint64(((itr->second.end - curMSTime) / IN_MILLISECONDS) + curTime);
3551  ss << '(' << GetGUID().GetCounter() << ',' << itr->first << ',' << itr->second.category << "," << itr->second.itemid << ',' << cooldown << ',' << (itr->second.needSendToClient ? '1' : '0') << ')';
3552  ++itr;
3553  }
3554  else
3555  ++itr;
3556  }
3557  // if something changed execute
3558  if (!first_round)
3559  trans->Append(ss.str().c_str());
3560 }
3561 
3563 {
3564  // The first time reset costs 1 gold
3565  if (m_resetTalentsCost < 1 * GOLD)
3566  return 1 * GOLD;
3567  // then 5 gold
3568  else if (m_resetTalentsCost < 5 * GOLD)
3569  return 5 * GOLD;
3570  // After that it increases in increments of 5 gold
3571  else if (m_resetTalentsCost < 10 * GOLD)
3572  return 10 * GOLD;
3573  else
3574  {
3575  uint64 months = (sWorld->GetGameTime() - m_resetTalentsTime) / MONTH;
3576  if (months > 0)
3577  {
3578  // This cost will be reduced by a rate of 5 gold per month
3579  int32 new_cost = int32(m_resetTalentsCost - 5 * GOLD * months);
3580  // to a minimum of 10 gold.
3581  return (new_cost < 10 * GOLD ? 10 * GOLD : new_cost);
3582  }
3583  else
3584  {
3585  // After that it increases in increments of 5 gold
3586  int32 new_cost = m_resetTalentsCost + 5 * GOLD;
3587  // until it hits a cap of 50 gold.
3588  if (new_cost > 50 * GOLD)
3589  new_cost = 50 * GOLD;
3590  return new_cost;
3591  }
3592  }
3593 }
3594 
3595 bool Player::resetTalents(bool noResetCost)
3596 {
3597  sScriptMgr->OnPlayerTalentsReset(this, noResetCost);
3598 
3599  // xinef: remove at login flag upon talents reset
3602 
3603  // xinef: get max available talent points amount
3604  uint32 talentPointsForLevel = CalculateTalentsPoints();
3605 
3606  // xinef: no talent points are used, return
3607  if (m_usedTalentCount == 0)
3608  return false;
3609  m_usedTalentCount = 0;
3610 
3611  // xinef: check if we have enough money
3612  uint32 resetCost = 0;
3613  if (!noResetCost && !sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST))
3614  {
3615  resetCost = resetTalentsCost();
3616  if (!HasEnoughMoney(resetCost))
3617  {
3619  return false;
3620  }
3621  }
3622 
3623  RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
3624 
3625  // xinef: reset talents
3626  for (PlayerTalentMap::iterator iter = m_talents.begin(); iter != m_talents.end(); )
3627  {
3628  PlayerTalentMap::iterator itr = iter++;
3629 
3630  if (itr->second->State == PLAYERSPELL_REMOVED)
3631  continue;
3632 
3633  // xinef: talent not in current spec
3634  if (!(itr->second->specMask & GetActiveSpecMask()))
3635  continue;
3636 
3637  // xinef: remove talent auras
3638  _removeTalentAurasAndSpells(itr->first);
3639 
3640  // xinef: check if talent learns spell to spell book
3641  TalentEntry const* talentInfo = sTalentStore.LookupEntry(itr->second->talentID);
3642  const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
3643 
3644  bool removed = false;
3645  if (talentInfo->addToSpellBook)
3646  if (!spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
3647  {
3648  removeSpell(itr->first, GetActiveSpecMask(), false);
3649  removed = true;
3650  }
3651 
3652  // Xinef: send unlearn spell packet at talent remove
3653  if (!removed)
3654  SendLearnPacket(itr->first, false);
3655 
3656  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3657  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
3658  if (sSpellMgr->IsAdditionalTalentSpell(spellInfo->Effects[i].TriggerSpell))
3659  removeSpell(spellInfo->Effects[i].TriggerSpell, GetActiveSpecMask(), false);
3660 
3661  // xinef: remove talent modifies m_talents, move itr to map begin
3663  }
3664 
3665  // xinef: remove titan grip if player had it set
3666  if (m_canTitanGrip)
3667  SetCanTitanGrip(false);
3668  // xinef: remove dual wield if player does not have dual wield spell (shamans)
3669  if (!HasSpell(674) && m_canDualWield)
3670  SetCanDualWield(false);
3671 
3673 
3674  // pussywizard: removed saving to db, nothing important happens and saving only spells and talents may cause data integrity problems (eg. with skills saved to db)
3675  SetFreeTalentPoints(talentPointsForLevel);
3676 
3677  if (!noResetCost)
3678  {
3679  ModifyMoney(-(int32)resetCost);
3682 
3683  m_resetTalentsCost = resetCost;
3684  m_resetTalentsTime = time(nullptr);
3685  }
3686 
3687  return true;
3688 }
3689 
3691 {
3692  sScriptMgr->OnPlayerFreeTalentPointsChanged(this, points);
3694 }
3695 
3697 {
3698  for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
3699  {
3700  if ((*itr)->messageID == id)
3701  {
3702  return (*itr);
3703  }
3704  }
3705  return nullptr;
3706 }
3707 
3709 {
3710  if (target == this)
3711  {
3712  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
3713  {
3714  if (m_items[i] == nullptr)
3715  continue;
3716 
3717  m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
3718  }
3719 
3721  {
3722  if (m_items[i] == nullptr)
3723  continue;
3724 
3725  m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
3726  }
3727  for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
3728  {
3729  if (m_items[i] == nullptr)
3730  continue;
3731 
3732  m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
3733  }
3734  }
3735 
3737 }
3738 
3739 void Player::DestroyForPlayer(Player* target, bool onDeath) const
3740 {
3741  Unit::DestroyForPlayer(target, onDeath);
3742 
3743  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) // xinef: previously INVENTORY_SLOT_BAG_END
3744  {
3745  if (m_items[i] == nullptr)
3746  continue;
3747 
3748  m_items[i]->DestroyForPlayer(target);
3749  }
3750 
3751  if (target == this)
3752  {
3754  {
3755  if (m_items[i] == nullptr)
3756  continue;
3757 
3758  m_items[i]->DestroyForPlayer(target);
3759  }
3760  for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
3761  {
3762  if (m_items[i] == nullptr)
3763  continue;
3764 
3765  m_items[i]->DestroyForPlayer(target);
3766  }
3767  }
3768 }
3769 
3770 bool Player::HasSpell(uint32 spell) const
3771 {
3772  PlayerSpellMap::const_iterator itr = m_spells.find(spell);
3773  return (itr != m_spells.end() && itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(m_activeSpec));
3774 }
3775 
3776 bool Player::HasTalent(uint32 spell, uint8 /*spec*/) const
3777 {
3778  PlayerTalentMap::const_iterator itr = m_talents.find(spell);
3779  return (itr != m_talents.end() && itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(m_activeSpec));
3780 }
3781 
3783 {
3784  PlayerSpellMap::const_iterator itr = m_spells.find(spell);
3785  return (itr != m_spells.end() && itr->second->State != PLAYERSPELL_REMOVED && itr->second->Active && itr->second->IsInSpec(m_activeSpec));
3786 }
3787 
3789 {
3790  if (!trainer_spell)
3791  return TRAINER_SPELL_RED;
3792 
3793  bool hasSpell = true;
3794  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3795  {
3796  if (!trainer_spell->learnedSpell[i])
3797  continue;
3798 
3799  if (!HasSpell(trainer_spell->learnedSpell[i]))
3800  {
3801  hasSpell = false;
3802  break;
3803  }
3804  }
3805  // known spell
3806  if (hasSpell)
3807  return TRAINER_SPELL_GRAY;
3808 
3809  // check skill requirement
3810  if (trainer_spell->reqSkill && GetBaseSkillValue(trainer_spell->reqSkill) < trainer_spell->reqSkillValue)
3811  return TRAINER_SPELL_RED;
3812 
3813  // check level requirement
3814  if (getLevel() < trainer_spell->reqLevel)
3815  return TRAINER_SPELL_RED;
3816 
3817  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3818  {
3819  if (!trainer_spell->learnedSpell[i])
3820  continue;
3821 
3822  // check race/class requirement
3823  if (!IsSpellFitByClassAndRace(trainer_spell->learnedSpell[i]))
3824  return TRAINER_SPELL_RED;
3825 
3826  if (uint32 prevSpell = sSpellMgr->GetPrevSpellInChain(trainer_spell->learnedSpell[i]))
3827  {
3828  // check prev.rank requirement
3829  if (prevSpell && !HasSpell(prevSpell))
3830  return TRAINER_SPELL_RED;
3831  }
3832 
3833  SpellsRequiringSpellMapBounds spellsRequired = sSpellMgr->GetSpellsRequiredForSpellBounds(trainer_spell->learnedSpell[i]);
3834  for (SpellsRequiringSpellMap::const_iterator itr = spellsRequired.first; itr != spellsRequired.second; ++itr)
3835  {
3836  // check additional spell requirement
3837  if (!HasSpell(itr->second))
3838  return TRAINER_SPELL_RED;
3839  }
3840  }
3841 
3842  // check primary prof. limit
3843  // first rank of primary profession spell when there are no proffesions avalible is disabled
3844  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
3845  {
3846  if (!trainer_spell->learnedSpell[i])
3847  continue;
3848  SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainer_spell->learnedSpell[i]);
3849  if (learnedSpellInfo && learnedSpellInfo->IsPrimaryProfessionFirstRank() && (GetFreePrimaryProfessionPoints() == 0))
3851  }
3852 
3853  return TRAINER_SPELL_GREEN;
3854 }
3855 
3866 void Player::DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
3867 {
3868  // for not existed account avoid update realm
3869  if (!accountId)
3870  updateRealmChars = false;
3871 
3872  ObjectGuid playerGuid = ObjectGuid::Create<HighGuid::Player>(lowGuid);
3873 
3874  uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD);
3875  uint32 charDelete_minLvl = sWorld->getIntConfig(CONFIG_CHARDELETE_MIN_LEVEL);
3876 
3877  // if we want to finally delete the character or the character does not meet the level requirement,
3878  // we set it to mode CHAR_DELETE_REMOVE
3879  if (deleteFinally || Player::GetLevelFromStorage(lowGuid) < charDelete_minLvl)
3880  charDelete_method = CHAR_DELETE_REMOVE;
3881 
3882  if (uint32 guildId = GetGuildIdFromStorage(lowGuid))
3883  if (Guild* guild = sGuildMgr->GetGuildById(guildId))
3884  guild->DeleteMember(playerGuid, false, false, true);
3885 
3886  // remove from arena teams
3887  LeaveAllArenaTeams(playerGuid);
3888 
3889  // close player ticket if any
3890  GmTicket* ticket = sTicketMgr->GetTicketByPlayer(playerGuid);
3891  if (ticket)
3892  sTicketMgr->CloseTicket(ticket->GetId(), playerGuid);
3893 
3894  // remove from group
3895  if (uint32 groupId = GetGroupIdFromStorage(lowGuid))
3896  if (Group* group = sGroupMgr->GetGroupByGUID(groupId))
3897  RemoveFromGroup(group, playerGuid);
3898 
3899  // Remove signs from petitions (also remove petitions if owner);
3900  RemovePetitionsAndSigns(playerGuid, 10);
3901 
3902  CharacterDatabasePreparedStatement* stmt = nullptr;
3903 
3904  switch (charDelete_method)
3905  {
3906  // Completely remove from the database
3907  case CHAR_DELETE_REMOVE:
3908  {
3909  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3910 
3911  stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_COD_ITEM_MAIL);
3912  stmt->setUInt32(0, lowGuid);
3913  PreparedQueryResult resultMail = CharacterDatabase.Query(stmt);
3914 
3915  if (resultMail)
3916  {
3917  std::unordered_map<uint32, std::vector<Item*>> itemsByMail;
3918 
3919  stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAILITEMS);
3920  stmt->setUInt32(0, lowGuid);
3921  PreparedQueryResult resultItems = CharacterDatabase.Query(stmt);
3922 
3923  if (resultItems)
3924  {
3925  do
3926  {
3927  Field* fields = resultItems->Fetch();
3928  uint32 mailId = fields[14].GetUInt32();
3929  if (Item* mailItem = _LoadMailedItem(playerGuid, nullptr, mailId, nullptr, fields))
3930  {
3931  itemsByMail[mailId].push_back(mailItem);
3932  }
3933  } while (resultItems->NextRow());
3934  }
3935 
3936  do
3937  {
3938  Field* mailFields = resultMail->Fetch();
3939 
3940  uint32 mail_id = mailFields[0].GetUInt32();
3941  uint8 mailType = mailFields[1].GetUInt8();
3942  uint16 mailTemplateId = mailFields[2].GetUInt16();
3943  uint32 sender = mailFields[3].GetUInt32();
3944  std::string subject = mailFields[4].GetString();
3945  std::string body = mailFields[5].GetString();
3946  uint32 money = mailFields[6].GetUInt32();
3947  bool has_items = mailFields[7].GetBool();
3948 
3949  // We can return mail now
3950  // So firstly delete the old one
3951  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
3952  stmt->setUInt32(0, mail_id);
3953  trans->Append(stmt);
3954 
3955  // Mail is not from player
3956  if (mailType != MAIL_NORMAL)
3957  {
3958  if (has_items)
3959  {
3960  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
3961  stmt->setUInt32(0, mail_id);
3962  trans->Append(stmt);
3963  }
3964  continue;
3965  }
3966 
3967  MailDraft draft(subject, body);
3968  if (mailTemplateId)
3969  draft = MailDraft(mailTemplateId, false); // items are already included
3970 
3971  auto itemsItr = itemsByMail.find(mail_id);
3972  if (itemsItr != itemsByMail.end())
3973  {
3974  for (Item* item : itemsItr->second)
3975  {
3976  draft.AddItem(item);
3977  }
3978 
3979  // MailDraft will take care of freeing memory.
3980  itemsByMail.erase(itemsItr);
3981  }
3982 
3983  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
3984  stmt->setUInt32(0, mail_id);
3985  trans->Append(stmt);
3986 
3987  uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(lowGuid);
3988 
3989  draft.AddMoney(money).SendReturnToSender(pl_account, lowGuid, sender, trans);
3990  } while (resultMail->NextRow());
3991  }
3992 
3993  // Unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet.
3994  // NOW we can finally clear other DB data related to character
3995  stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PETS);
3996  stmt->setUInt32(0, lowGuid);
3997  PreparedQueryResult resultPets = CharacterDatabase.Query(stmt);
3998 
3999  if (resultPets)
4000  {
4001  do
4002  {
4003  ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32();
4004  Pet::DeleteFromDB(petguidlow);
4005  } while (resultPets->NextRow());
4006  }
4007 
4008  // Delete char from social list of online chars
4009  stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_SOCIAL);
4010  stmt->setUInt32(0, lowGuid);
4011  PreparedQueryResult resultFriends = CharacterDatabase.Query(stmt);
4012 
4013  if (resultFriends)
4014  {
4015  do
4016  {
4017  if (Player* pFriend = ObjectAccessor::FindPlayerByLowGUID((*resultFriends)[0].GetUInt32()))
4018  {
4019  pFriend->GetSocial()->RemoveFromSocialList(playerGuid, SOCIAL_FLAG_ALL);
4020  sSocialMgr->SendFriendStatus(pFriend, FRIEND_REMOVED, playerGuid, false);
4021  }
4022  } while (resultFriends->NextRow());
4023  }
4024 
4025  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER);
4026  stmt->setUInt32(0, lowGuid);
4027  trans->Append(stmt);
4028 
4029  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA);
4030  stmt->setUInt32(0, lowGuid);
4031  trans->Append(stmt);
4032 
4033  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME);
4034  stmt->setUInt32(0, lowGuid);
4035  trans->Append(stmt);
4036 
4037  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION);
4038  stmt->setUInt32(0, lowGuid);
4039  trans->Append(stmt);
4040 
4041  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA);
4042  stmt->setUInt32(0, lowGuid);
4043  trans->Append(stmt);
4044 
4045  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GIFT);
4046  stmt->setUInt32(0, lowGuid);
4047  trans->Append(stmt);
4048 
4049  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND);
4050  stmt->setUInt32(0, lowGuid);
4051  trans->Append(stmt);
4052 
4053  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE);
4054  stmt->setUInt32(0, lowGuid);
4055  trans->Append(stmt);
4056 
4057  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY);
4058  stmt->setUInt32(0, lowGuid);
4059  trans->Append(stmt);
4060 
4061  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS);
4062  stmt->setUInt32(0, lowGuid);
4063  trans->Append(stmt);
4064 
4065  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED);
4066  stmt->setUInt32(0, lowGuid);
4067  trans->Append(stmt);
4068 
4069  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION);
4070  stmt->setUInt32(0, lowGuid);
4071  trans->Append(stmt);
4072 
4073  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL);
4074  stmt->setUInt32(0, lowGuid);
4075  trans->Append(stmt);
4076 
4077  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_COOLDOWN);
4078  stmt->setUInt32(0, lowGuid);
4079  trans->Append(stmt);
4080 
4081  if (sWorld->getBoolConfig(CONFIG_DELETE_CHARACTER_TICKET_TRACE))
4082  {
4084  stmt->setUInt32(0, lowGuid);
4085  trans->Append(stmt);
4086  }
4087  else
4088  {
4089  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS);
4090  stmt->setUInt32(0, lowGuid);
4091  trans->Append(stmt);
4092  }
4093 
4094  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER);
4095  stmt->setUInt32(0, lowGuid);
4096  trans->Append(stmt);
4097 
4098  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND);
4099  stmt->setUInt32(0, lowGuid);
4100  trans->Append(stmt);
4101 
4102  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID);
4103  stmt->setUInt32(0, lowGuid);
4104  trans->Append(stmt);
4105 
4106  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL);
4107  stmt->setUInt32(0, lowGuid);
4108  trans->Append(stmt);
4109 
4110  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEMS);
4111  stmt->setUInt32(0, lowGuid);
4112  trans->Append(stmt);
4113 
4114  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_OWNER);
4115  stmt->setUInt32(0, lowGuid);
4116  trans->Append(stmt);
4117 
4118  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER);
4119  stmt->setUInt32(0, lowGuid);
4120  trans->Append(stmt);
4121 
4122  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENTS);
4123  stmt->setUInt32(0, lowGuid);
4124  trans->Append(stmt);
4125 
4126  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
4127  stmt->setUInt32(0, lowGuid);
4128  trans->Append(stmt);
4129 
4130  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_EQUIPMENTSETS);
4131  stmt->setUInt32(0, lowGuid);
4132  trans->Append(stmt);
4133 
4134  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER);
4135  stmt->setUInt32(0, lowGuid);
4136  stmt->setUInt32(1, lowGuid);
4137  trans->Append(stmt);
4138 
4139  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER);
4140  stmt->setUInt32(0, lowGuid);
4141  trans->Append(stmt);
4142 
4143  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ENTRY_POINT);
4144  stmt->setUInt32(0, lowGuid);
4145  trans->Append(stmt);
4146 
4147  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS);
4148  stmt->setUInt32(0, lowGuid);
4149  trans->Append(stmt);
4150 
4151  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_DAILY_CHAR);
4152  stmt->setUInt32(0, lowGuid);
4153  trans->Append(stmt);
4154 
4155  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_WEEKLY_CHAR);
4156  stmt->setUInt32(0, lowGuid);
4157  trans->Append(stmt);
4158 
4159  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_MONTHLY_CHAR);
4160  stmt->setUInt32(0, lowGuid);
4161  trans->Append(stmt);
4162 
4163  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR);
4164  stmt->setUInt32(0, lowGuid);
4165  trans->Append(stmt);
4166 
4167  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT);
4168  stmt->setUInt32(0, lowGuid);
4169  trans->Append(stmt);
4170 
4171  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILLS);
4172  stmt->setUInt32(0, lowGuid);
4173  trans->Append(stmt);
4174 
4175  Corpse::DeleteFromDB(playerGuid, trans);
4176 
4177  sScriptMgr->OnDeleteFromDB(trans, lowGuid);
4178 
4179  CharacterDatabase.CommitTransaction(trans);
4180  break;
4181  }
4182  // The character gets unlinked from the account, the name gets freed up and appears as deleted ingame
4183  case CHAR_DELETE_UNLINK:
4184  {
4185  stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO);
4186 
4187  stmt->setUInt32(0, lowGuid);
4188 
4189  CharacterDatabase.Execute(stmt);
4190  break;
4191  }
4192  default:
4193  LOG_ERROR("entities.player", "Player::DeleteFromDB: Unsupported delete method: %u.", charDelete_method);
4194  return;
4195  }
4196 
4197  if (updateRealmChars)
4198  sWorld->UpdateRealmCharCount(accountId);
4199 }
4200 
4205 {
4206  uint32 keepDays = sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS);
4207  if (!keepDays)
4208  return;
4209 
4210  Player::DeleteOldCharacters(keepDays);
4211 }
4212 
4217 {
4218  LOG_INFO("server.loading", "Player::DeleteOldChars: Deleting all characters which have been deleted %u days before...", keepDays);
4219  LOG_INFO("server.loading", " ");
4220 
4222  stmt->setUInt32(0, uint32(time(nullptr) - time_t(keepDays * DAY)));
4223  PreparedQueryResult result = CharacterDatabase.Query(stmt);
4224 
4225  if (result)
4226  {
4227  LOG_INFO("server.loading", "Player::DeleteOldChars: Found " UI64FMTD " character(s) to delete", result->GetRowCount());
4228  do
4229  {
4230  Field* fields = result->Fetch();
4231  Player::DeleteFromDB(fields[0].GetUInt32(), fields[1].GetUInt32(), true, true);
4232  } while (result->NextRow());
4233  }
4234 }
4235 
4237 {
4238  WorldPacket data;
4239  switch (pType)
4240  {
4241  case MOVE_ROOT:
4242  data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size() + 4);
4243  break;
4244  case MOVE_UNROOT:
4245  data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size() + 4);
4246  break;
4247  case MOVE_WATER_WALK:
4248  data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size() + 4);
4249  break;
4250  case MOVE_LAND_WALK:
4251  data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4);
4252  break;
4253  default:
4254  LOG_ERROR("entities.player", "Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType);
4255  return;
4256  }
4257  data << GetPackGUID();
4258  data << uint32(0);
4259  GetSession()->SendPacket(&data);
4260 }
4261 
4262 /* Preconditions:
4263  - a resurrectable corpse must not be loaded for the player (only bones)
4264  - the player must be in world
4265 */
4267 {
4268  WorldPacket data(SMSG_PRE_RESURRECT, GetPackGUID().size());
4269  data << GetPackGUID();
4270  GetSession()->SendPacket(&data);
4271  if (getRace(true) == RACE_NIGHTELF)
4272  {
4273  CastSpell(this, 20584, true);
4274  }
4275  CastSpell(this, 8326, true);
4276 
4277  // there must be SMSG.FORCE_RUN_SPEED_CHANGE, SMSG.FORCE_SWIM_SPEED_CHANGE, SMSG.MOVE_WATER_WALK
4278  // there must be SMSG.STOP_MIRROR_TIMER
4279 
4280  // the player cannot have a corpse already on current map, only bones which are not returned by GetCorpse
4281  WorldLocation corpseLocation = GetCorpseLocation();
4282  if (GetCorpse() && corpseLocation.GetMapId() == GetMapId())
4283  {
4284  LOG_ERROR("entities.player", "BuildPlayerRepop: player %s (%s) already has a corpse", GetName().c_str(), GetGUID().ToString().c_str());
4285  return;
4286  }
4287 
4288  // create a corpse and place it at the player's location
4289  Corpse* corpse = CreateCorpse();
4290  if (!corpse)
4291  {
4292  LOG_ERROR("entities.player", "Error creating corpse for Player %s [%s]", GetName().c_str(), GetGUID().ToString().c_str());
4293  return;
4294  }
4295  GetMap()->AddToMap(corpse);
4296  SetHealth(1); // convert player body to ghost
4298  SetWaterWalking(true);
4299  if (!GetSession()->isLogingOut())
4300  {
4302  }
4303  RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // BG - remove insignia related
4304  int32 corpseReclaimDelay = CalculateCorpseReclaimDelay();
4305  if (corpseReclaimDelay >= 0)
4306  {
4307  SendCorpseReclaimDelay(corpseReclaimDelay);
4308  }
4309  corpse->ResetGhostTime(); // to prevent cheating
4310  StopMirrorTimers(); // disable timers on bars
4312  sScriptMgr->OnPlayerReleasedGhost(this);
4313 }
4314 
4315 void Player::ResurrectPlayer(float restore_percent, bool applySickness)
4316 {
4317  WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // remove spirit healer position
4318  data << uint32(-1);
4319  data << float(0);
4320  data << float(0);
4321  data << float(0);
4322  GetSession()->SendPacket(&data);
4323 
4324  // speed change, land walk
4325 
4326  // remove death flag + set aura
4328  RemoveAurasDueToSpell(20584); // speed bonuses
4329  RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST
4330 
4331  if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
4333 
4337  SetWaterWalking(false);
4338  m_deathTimer = 0;
4339 
4340  // set health/powers (0- will be set in caller)
4341  if (restore_percent > 0.0f)
4342  {
4343  SetHealth(uint32(GetMaxHealth()*restore_percent));
4344  SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent));
4345  SetPower(POWER_RAGE, 0);
4346  SetPower(POWER_ENERGY, uint32(GetMaxPower(POWER_ENERGY)*restore_percent));
4347  }
4348 
4349  // trigger update zone for alive state zone updates
4350  uint32 newzone, newarea;
4351  GetZoneAndAreaId(newzone, newarea);
4352  UpdateZone(newzone, newarea);
4353  sOutdoorPvPMgr->HandlePlayerResurrects(this, newzone);
4354 
4355  if (Battleground* bg = GetBattleground())
4356  bg->HandlePlayerResurrect(this);
4357 
4358  // update visibility
4360 
4361 #ifdef ELUNA
4362  sEluna->OnResurrect(this);
4363 #endif
4364 
4365  if(!applySickness)
4366  return;
4367 
4368  //Characters from level 1-10 are not affected by resurrection sickness.
4369  //Characters from level 11-19 will suffer from one minute of sickness
4370  //for each level they are above 10.
4371  //Characters level 20 and up suffer from ten minutes of sickness.
4372  int32 startLevel = sWorld->getIntConfig(CONFIG_DEATH_SICKNESS_LEVEL);
4373 
4374  if (int32(getLevel()) >= startLevel)
4375  {
4376  // set resurrection sickness
4377  CastSpell(this, 15007, true);
4378 
4379  // not full duration
4380  if (int32(getLevel()) < startLevel + 9)
4381  {
4382  int32 delta = (int32(getLevel()) - startLevel + 1) * MINUTE;
4383 
4384  if (Aura* aur = GetAura(15007, GetGUID()))
4385  {
4386  aur->SetDuration(delta * IN_MILLISECONDS);
4387  }
4388  }
4389  }
4390 }
4391 
4393 {
4394  if (IsFlying() && !GetTransport())
4396 
4398 
4399  StopMirrorTimers(); //disable timers(bars)
4400 
4402  //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP);
4403 
4406 
4407  // 6 minutes until repop at graveyard
4409 
4410  UpdateCorpseReclaimDelay(); // dependent at use SetDeathPvP() call before kill
4411 
4412  int32 corpseReclaimDelay = CalculateCorpseReclaimDelay();
4413 
4414  if (corpseReclaimDelay >= 0)
4415  SendCorpseReclaimDelay(corpseReclaimDelay);
4416 
4417  // don't create corpse at this moment, player might be falling
4418 
4419  // update visibility
4420  //UpdateObjectVisibility(); // pussywizard: not needed
4421 }
4422 
4424 {
4425  Corpse::DeleteFromDB(guid, trans);
4427  stmt->setUInt16(0, uint16(AT_LOGIN_RESURRECT));
4428  stmt->setUInt64(1, guid.GetCounter());
4429  CharacterDatabase.ExecuteOrAppend(trans, stmt);
4430 }
4431 
4433 {
4434  // prevent existence 2 corpse for player
4435  SpawnCorpseBones();
4436 
4437  uint32 _uf, _pb, _pb2, _cfb1, _cfb2;
4438 
4440  SetPvPDeath(false);
4441 
4442  if (!corpse->Create(GetMap()->GenerateLowGuid<HighGuid::Corpse>(), this))
4443  {
4444  delete corpse;
4445  return nullptr;
4446  }
4447 
4449 
4450  _uf = getRace();
4453 
4454  uint8 race = (uint8)(_uf);
4455  uint8 skin = (uint8)(_pb);
4456  uint8 face = (uint8)(_pb >> 8);
4457  uint8 hairstyle = (uint8)(_pb >> 16);
4458  uint8 haircolor = (uint8)(_pb >> 24);
4459  uint8 facialhair = (uint8)(_pb2);
4460 
4461  _cfb1 = ((0x00) | (race << 8) | (GetByteValue(PLAYER_BYTES_3, 0) << 16) | (skin << 24));
4462  _cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
4463 
4464  corpse->SetUInt32Value(CORPSE_FIELD_BYTES_1, _cfb1);
4465  corpse->SetUInt32Value(CORPSE_FIELD_BYTES_2, _cfb2);
4466 
4467  uint32 flags = CORPSE_FLAG_UNK2;
4469  flags |= CORPSE_FLAG_HIDE_HELM;
4471  flags |= CORPSE_FLAG_HIDE_CLOAK;
4472 
4473  // Xinef: Player can loop corpses while in BG or in WG
4474  if (InBattleground() && !InArena())
4475  flags |= CORPSE_FLAG_LOOTABLE;
4476  Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
4477  if (Bf && Bf->IsWarTime())
4478  flags |= CORPSE_FLAG_LOOTABLE;
4479 
4480  corpse->SetUInt32Value(CORPSE_FIELD_FLAGS, flags);
4481 
4483 
4485 
4486  uint32 iDisplayID;
4487  uint32 iIventoryType;
4488  uint32 _cfi;
4489  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; i++)
4490  {
4491  if (m_items[i])
4492  {
4493  iDisplayID = m_items[i]->GetTemplate()->DisplayInfoID;
4494  iIventoryType = m_items[i]->GetTemplate()->InventoryType;
4495 
4496  _cfi = iDisplayID | (iIventoryType << 24);
4497  corpse->SetUInt32Value(CORPSE_FIELD_ITEM + i, _cfi);
4498  }
4499  }
4500 
4501  // register for player, but not show
4502  GetMap()->AddCorpse(corpse);
4503 
4505 
4506  // we do not need to save corpses for BG/arenas
4507  if (!GetMap()->IsBattlegroundOrArena())
4508  corpse->SaveToDB();
4509 
4510  return corpse;
4511 }
4512 
4514 {
4515  if (GetCorpse())
4516  {
4518  }
4519 
4520  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
4521  Corpse::DeleteFromDB(GetGUID(), trans);
4522  CharacterDatabase.CommitTransaction(trans);
4523 }
4524 
4525 void Player::SpawnCorpseBones(bool triggerSave /*= true*/)
4526 {
4528  if (GetMap()->ConvertCorpseToBones(GetGUID()))
4529  if (triggerSave && !GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player
4530  {
4531  // prevent loading as ghost without corpse
4532  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
4533 
4534  // pussywizard: update only ghost flag instead of whole character table entry! data integrity is crucial
4536  stmt->setUInt32(0, GetGUID().GetCounter());
4537  trans->Append(stmt);
4538 
4539  _SaveAuras(trans, false);
4540 
4541  CharacterDatabase.CommitTransaction(trans);
4542  }
4543 }
4544 
4546 {
4547  return GetMap()->GetCorpseByPlayer(GetGUID());
4548 }
4549 
4550 void Player::DurabilityLossAll(double percent, bool inventory)
4551 {
4552  for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
4553  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
4554  DurabilityLoss(pItem, percent);
4555 
4556  if (inventory)
4557  {
4558  // bags not have durability
4559  // for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
4560 
4562  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
4563  DurabilityLoss(pItem, percent);
4564 
4565  // keys not have durability
4566  //for (int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++)
4567 
4569  if (Bag* pBag = GetBagByPos(i))
4570  for (uint32 j = 0; j < pBag->GetBagSize(); j++)
4571  if (Item* pItem = GetItemByPos(i, j))
4572  DurabilityLoss(pItem, percent);
4573  }
4574 }
4575 
4576 void Player::DurabilityLoss(Item* item, double percent)
4577 {
4578  if(!item)
4579  return;
4580 
4581  uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
4582 
4583  if (!pMaxDurability)
4584  return;
4585 
4586  uint32 pDurabilityLoss = uint32(pMaxDurability * percent);
4587 
4588  if (pDurabilityLoss < 1)
4589  pDurabilityLoss = 1;
4590 
4591  DurabilityPointsLoss(item, pDurabilityLoss);
4592 }
4593 
4594 void Player::DurabilityPointsLossAll(int32 points, bool inventory)
4595 {
4596  for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
4597  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
4598  DurabilityPointsLoss(pItem, points);
4599 
4600  if (inventory)
4601  {
4602  // bags not have durability
4603  // for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
4604 
4606  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
4607  DurabilityPointsLoss(pItem, points);
4608 
4609  // keys not have durability
4610  //for (int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++)
4611 
4613  if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
4614  for (uint32 j = 0; j < pBag->GetBagSize(); j++)
4615  if (Item* pItem = GetItemByPos(i, j))
4616  DurabilityPointsLoss(pItem, points);
4617  }
4618 }
4619 
4621 {
4623  {
4624  return;
4625  }
4626 
4627  int32 pMaxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
4628  int32 pOldDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY);
4629  int32 pNewDurability = pOldDurability - points;
4630 
4631  if (pNewDurability < 0)
4632  pNewDurability = 0;
4633  else if (pNewDurability > pMaxDurability)
4634  pNewDurability = pMaxDurability;
4635 
4636  if (pOldDurability != pNewDurability)
4637  {
4638  // modify item stats _before_ Durability set to 0 to pass _ApplyItemMods internal check
4639  if (pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped())
4640  _ApplyItemMods(item, item->GetSlot(), false);
4641 
4642  item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability);
4643 
4644  // modify item stats _after_ restore durability to pass _ApplyItemMods internal check
4645  if (pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped())
4646  _ApplyItemMods(item, item->GetSlot(), true);
4647 
4648  item->SetState(ITEM_CHANGED, this);
4649  }
4650 }
4651 
4653 {
4654  if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
4655  DurabilityPointsLoss(pItem, 1);
4656 }
4657 
4658 uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank)
4659 {
4660  uint32 TotalCost = 0;
4661  // equipped, backpack, bags itself
4663  TotalCost += DurabilityRepair(((INVENTORY_SLOT_BAG_0 << 8) | i), cost, discountMod, guildBank);
4664 
4665  // bank, buyback and keys not repaired
4666 
4667  // items in inventory bags
4669  for (uint8 i = 0; i < MAX_BAG_SIZE; i++)
4670  TotalCost += DurabilityRepair(((j << 8) | i), cost, discountMod, guildBank);
4671  return TotalCost;
4672 }
4673 
4674 uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank)
4675 {
4676  Item* item = GetItemByPos(pos);
4677 
4678  uint32 TotalCost = 0;
4679  if (!item)
4680  return TotalCost;
4681 
4682  uint32 maxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
4683  if (!maxDurability)
4684  return TotalCost;
4685 
4686  uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY);
4687 
4688  if (cost)
4689  {
4690  uint32 LostDurability = maxDurability - curDurability;
4691  if (LostDurability > 0)
4692  {
4693  ItemTemplate const* ditemProto = item->GetTemplate();
4694 
4695  DurabilityCostsEntry const* dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel);
4696  if (!dcost)
4697  {
4698  LOG_ERROR("entities.player", "RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel);
4699  return TotalCost;
4700  }
4701 
4702  uint32 dQualitymodEntryId = (ditemProto->Quality + 1) * 2;
4703  DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId);
4704  if (!dQualitymodEntry)
4705  {
4706  LOG_ERROR("entities.player", "RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId);
4707  return TotalCost;
4708  }
4709 
4710  uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)];
4711  uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod));
4712 
4713  costs = uint32(costs * discountMod * sWorld->getRate(RATE_REPAIRCOST));
4714 
4715  if (costs == 0) //fix for ITEM_QUALITY_ARTIFACT
4716  costs = 1;
4717 
4718  if (guildBank)
4719  {
4720  if (GetGuildId() == 0)
4721  {
4722  // LOG_DEBUG("entities.player", "You are not member of a guild");
4723  return TotalCost;
4724  }
4725 
4726  Guild* guild = sGuildMgr->GetGuildById(GetGuildId());
4727  if (!guild)
4728  return TotalCost;
4729 
4730  if (!guild->HandleMemberWithdrawMoney(GetSession(), costs, true))
4731  return TotalCost;
4732 
4733  TotalCost = costs;
4734  }
4735  else if (!HasEnoughMoney(costs))
4736  {
4737  // LOG_DEBUG("entities.player", "You do not have enough money");
4738  return TotalCost;
4739  }
4740  else
4741  ModifyMoney(-int32(costs));
4742  }
4743  }
4744 
4745  item->SetUInt32Value(ITEM_FIELD_DURABILITY, maxDurability);
4746  item->SetState(ITEM_CHANGED, this);
4747 
4748  // reapply mods for total broken and repaired item if equipped
4749  if (IsEquipmentPos(pos) && !curDurability)
4750  _ApplyItemMods(item, pos & 255, true);
4751  return TotalCost;
4752 }
4753 
4755 {
4756  // note: this can be called also when the player is alive
4757  // for example from WorldSession::HandleMovementOpcodes
4758 
4759  AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetAreaId());
4760 
4761  if (!sScriptMgr->CanRepopAtGraveyard(this))
4762  return;
4763 
4764  // Such zones are considered unreachable as a ghost and the player must be automatically revived
4765  // Xinef: Get Transport Check is not needed
4766  if ((!IsAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY) /*|| GetTransport()*/ || GetPositionZ() < GetMap()->GetMinHeight(GetPositionX(), GetPositionY()))
4767  {
4768  ResurrectPlayer(0.5f);
4769  SpawnCorpseBones();
4770  }
4771 
4772  GraveyardStruct const* ClosestGrave = nullptr;
4773 
4774  // Special handle for battleground maps
4775  if (Battleground* bg = GetBattleground())
4776  ClosestGrave = bg->GetClosestGraveyard(this);
4777  else
4778  {
4779  if (sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
4780  ClosestGrave = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId())->GetClosestGraveyard(this);
4781  else
4782  ClosestGrave = sGraveyard->GetClosestGraveyard(this, GetTeamId());
4783  }
4784 
4785  // stop countdown until repop
4786  m_deathTimer = 0;
4787 
4788  // if no grave found, stay at the current location
4789  // and don't show spirit healer location
4790  if (ClosestGrave)
4791  {
4792  TeleportTo(ClosestGrave->Map, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
4793  if (isDead()) // not send if alive, because it used in TeleportTo()
4794  {
4795  WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // show spirit healer position on minimap
4796  data << ClosestGrave->Map;
4797  data << ClosestGrave->x;
4798  data << ClosestGrave->y;
4799  data << ClosestGrave->z;
4800  GetSession()->SendPacket(&data);
4801  }
4802  }
4803  else if (GetPositionZ() < GetMap()->GetMinHeight(GetPositionX(), GetPositionY()))
4805 
4807 }
4808 
4810 {
4811  // Player can join LFG anywhere
4812  if (channel->flags & CHANNEL_DBC_FLAG_LFG && sWorld->getBoolConfig(CONFIG_LFG_LOCATION_ALL))
4813  return true;
4814 
4816  return false;
4817 
4818  if ((channel->flags & CHANNEL_DBC_FLAG_CITY_ONLY) && (!(zone->flags & AREA_FLAG_SLAVE_CAPITAL)))
4819  return false;
4820 
4821  if ((channel->flags & CHANNEL_DBC_FLAG_GUILD_REQ) && GetGuildId())
4822  return false;
4823 
4824  return true;
4825 }
4826 
4828 {
4829  m_channels.push_back(c);
4830 }
4831 
4833 {
4834  m_channels.remove(c);
4835 }
4836 
4838 {
4839  while (!m_channels.empty())
4840  {
4841  Channel* ch = *m_channels.begin();
4842  m_channels.erase(m_channels.begin()); // remove from player's channel list
4843  ch->LeaveChannel(this, false); // not send to client, not remove from player's channel list
4844  }
4845 }
4846 
4848 {
4849  for (JoinedChannelsList::iterator itr = m_channels.begin(); itr != m_channels.end(); ++itr)
4850  (*itr)->RemoveWatching(this);
4851 }
4852 
4853 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply)
4854 {
4855  if (modGroup >= BASEMOD_END)
4856  {
4857  LOG_ERROR("entities.player", "ERROR in HandleBaseModValue(): non existed BaseModGroup!");
4858  return;
4859  }
4860 
4861  switch (modType)
4862  {
4863  case FLAT_MOD:
4864  m_auraBaseMod[modGroup][modType] += apply ? amount : -amount;
4865  break;
4866  case PCT_MOD:
4867  ApplyPercentModFloatVar(m_auraBaseMod[modGroup][modType], amount, apply);
4868  break;
4869  }
4870 
4871  if (!CanModifyStats())
4872  return;
4873 
4874  switch (modGroup)
4875  {
4876  case CRIT_PERCENTAGE:
4878  break;
4881  break;
4884  break;
4885  case SHIELD_BLOCK_VALUE:
4887  break;
4888  default:
4889  break;
4890  }
4891 }
4892 
4893 float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const
4894 {
4895  if (modGroup >= BASEMOD_END)
4896  {
4897  LOG_ERROR("entities.player", "trial to access non existed BaseModGroup!");
4898  return 0.0f;
4899  }
4900 
4901  if (modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f)
4902  return 0.0f;
4903 
4904  return m_auraBaseMod[modGroup][modType];
4905 }
4906 
4908 {
4909  if (modGroup >= BASEMOD_END)
4910  {
4911  LOG_ERROR("entities.player", "wrong BaseModGroup in GetTotalBaseModValue()!");
4912  return 0.0f;
4913  }
4914 
4915  if (m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f)
4916  return 0.0f;
4917 
4918  return m_auraBaseMod[modGroup][FLAT_MOD] * m_auraBaseMod[modGroup][PCT_MOD];
4919 }
4920 
4922 {
4924 
4925  value = (value < 0) ? 0 : value;
4926 
4927  return uint32(value);
4928 }
4929 
4931 {
4932  uint8 level = getLevel();
4933  uint32 pclass = getClass();
4934 
4935  if (level > GT_MAX_LEVEL)
4936  level = GT_MAX_LEVEL;
4937 
4938  GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass - 1);
4939  GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
4940  if (critBase == nullptr || critRatio == nullptr)
4941  return 0.0f;
4942 
4943  float crit = critBase->base + GetStat(STAT_AGILITY) * critRatio->ratio;
4944  return crit * 100.0f;
4945 }
4946 
4947 void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing)
4948 {
4949  // Table for base dodge values
4950  const float dodge_base[MAX_CLASSES] =
4951  {
4952  0.036640f, // Warrior
4953  0.034943f, // Paladi
4954  -0.040873f, // Hunter
4955  0.020957f, // Rogue
4956  0.034178f, // Priest
4957  0.036640f, // DK
4958  0.021080f, // Shaman
4959  0.036587f, // Mage
4960  0.024211f, // Warlock
4961  0.0f, // ??
4962  0.056097f // Druid
4963  };
4964  // Crit/agility to dodge/agility coefficient multipliers; 3.2.0 increased required agility by 15%
4965  const float crit_to_dodge[MAX_CLASSES] =
4966  {
4967  0.85f / 1.15f, // Warrior
4968  1.00f / 1.15f, // Paladin
4969  1.11f / 1.15f, // Hunter
4970  2.00f / 1.15f, // Rogue
4971  1.00f / 1.15f, // Priest
4972  0.85f / 1.15f, // DK
4973  1.60f / 1.15f, // Shaman
4974  1.00f / 1.15f, // Mage
4975  0.97f / 1.15f, // Warlock (?)
4976  0.0f, // ??
4977  2.00f / 1.15f // Druid
4978  };
4979 
4980  uint8 level = getLevel();
4981  uint32 pclass = getClass();
4982 
4983  if (level > GT_MAX_LEVEL)
4984  level = GT_MAX_LEVEL;
4985 
4986  // Dodge per agility is proportional to crit per agility, which is available from DBC files
4987  GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
4988  if (dodgeRatio == nullptr || pclass > MAX_CLASSES)
4989  return;
4990 
4991  // TODO: research if talents/effects that increase total agility by x% should increase non-diminishing part
4993  float bonus_agility = GetStat(STAT_AGILITY) - base_agility;
4994 
4995  // calculate diminishing (green in char screen) and non-diminishing (white) contribution
4996  diminishing = 100.0f * bonus_agility * dodgeRatio->ratio * crit_to_dodge[pclass - 1];
4997  nondiminishing = 100.0f * (dodge_base[pclass - 1] + base_agility * dodgeRatio->ratio * crit_to_dodge[pclass - 1]);
4998 }
4999 
5001 {
5002  uint8 level = getLevel();
5003  uint32 pclass = getClass();
5004 
5005  if (level > GT_MAX_LEVEL)
5006  level = GT_MAX_LEVEL;
5007 
5008  GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1);
5009  GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
5010  if (critBase == nullptr || critRatio == nullptr)
5011  return 0.0f;
5012 
5013  float crit = critBase->base + GetStat(STAT_INTELLECT) * critRatio->ratio;
5014  return crit * 100.0f;
5015 }
5016 
5018 {
5019  uint8 level = getLevel();
5020 
5021  if (level > GT_MAX_LEVEL)
5022  level = GT_MAX_LEVEL;
5023 
5024  GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr * GT_MAX_LEVEL + level - 1);
5025  // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1
5026  GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass() - 1) * GT_MAX_RATING + cr + 1);
5027  if (!Rating || !classRating)
5028  return 1.0f; // By default use minimum coefficient (not must be called)
5029 
5030  return classRating->ratio / Rating->ratio;
5031 }
5032 
5034 {
5035  return float(GetUInt32Value(static_cast<uint16>(PLAYER_FIELD_COMBAT_RATING_1) + cr)) * GetRatingMultiplier(cr);
5036 }
5037 
5039 {
5040  switch (attType)
5041  {
5042  case BASE_ATTACK:
5043  return GetUInt32Value(PLAYER_EXPERTISE) / 4.0f;
5044  case OFF_ATTACK:
5046  default:
5047  break;
5048  }
5049  return 0.0f;
5050 }
5051 
5053 {
5054  uint8 level = getLevel();
5055  uint32 pclass = getClass();
5056 
5057  if (level > GT_MAX_LEVEL)
5058  level = GT_MAX_LEVEL;
5059 
5060  GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
5061  GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
5062  if (baseRatio == nullptr || moreRatio == nullptr)
5063  return 0.0f;
5064 
5065  // Formula from PaperDollFrame script
5066  float spirit = GetStat(STAT_SPIRIT);
5067  float baseSpirit = spirit;
5068  if (baseSpirit > 50)
5069  baseSpirit = 50;
5070  float moreSpirit = spirit - baseSpirit;
5071  float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio;
5072  return regen;
5073 }
5074 
5076 {
5077  uint8 level = getLevel();
5078  uint32 pclass = getClass();
5079 
5080  if (level > GT_MAX_LEVEL)
5081  level = GT_MAX_LEVEL;
5082 
5083  // GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
5084  GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
5085  if (moreRatio == nullptr)
5086  return 0.0f;
5087 
5088  // Formula get from PaperDollFrame script
5089  float spirit = GetStat(STAT_SPIRIT);
5090  float regen = spirit * moreRatio->ratio;
5091  return regen;
5092 }
5093 
5095 {
5096  float oldRating = m_baseRatingValue[cr];
5097  m_baseRatingValue[cr] += (apply ? value : -value);
5098  // explicit affected values
5099  if (cr == CR_HASTE_MELEE || cr == CR_HASTE_RANGED || cr == CR_HASTE_SPELL)
5100  {
5101  float const mult = GetRatingMultiplier(cr);
5102  float const oldVal = oldRating * mult;
5103  float const newVal = m_baseRatingValue[cr] * mult;
5104  switch (cr)
5105  {
5106  case CR_HASTE_MELEE:
5107  ApplyAttackTimePercentMod(BASE_ATTACK, oldVal, false);
5108  ApplyAttackTimePercentMod(OFF_ATTACK, oldVal, false);
5109  ApplyAttackTimePercentMod(BASE_ATTACK, newVal, true);
5110  ApplyAttackTimePercentMod(OFF_ATTACK, newVal, true);
5111  break;
5112  case CR_HASTE_RANGED:
5113  ApplyAttackTimePercentMod(RANGED_ATTACK, oldVal, false);
5115  break;
5116  case CR_HASTE_SPELL:
5117  ApplyCastTimePercentMod(oldVal, false);
5118  ApplyCastTimePercentMod(newVal, true);
5119  break;
5120  default:
5121  break;
5122  }
5123  }
5124 
5125  UpdateRating(cr);
5126 }
5127 
5129 {
5130  for (uint8 i = 0; i < MAX_ATTACK; ++i)
5131  {
5132  Item* tmpitem = GetWeaponForAttack(WeaponAttackType(i), true);
5133  if (tmpitem && !tmpitem->IsBroken())
5134  {
5135  ItemTemplate const* proto = tmpitem->GetTemplate();
5136  if (proto->Delay)
5137  SetAttackTime(WeaponAttackType(i), proto->Delay);
5138  }
5139  else
5140  SetAttackTime(WeaponAttackType(i), BASE_ATTACK_TIME); // If there is no weapon reset attack time to base (might have been changed from forms)
5141  }
5142 }
5143 
5144 void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent)
5145 {
5146  SkillStatusMap::const_iterator itr = mSkillStatus.find(skillid);
5147  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5148  return;
5149 
5150  uint32 bonusIndex = PLAYER_SKILL_BONUS_INDEX(itr->second.pos);
5151 
5152  uint32 bonus_val = GetUInt32Value(bonusIndex);
5153  int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val);
5154  int16 perm_bonus = SKILL_PERM_BONUS(bonus_val);
5155 
5156  if (talent) // permanent bonus stored in high part
5157  SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus, perm_bonus + val));
5158  else // temporary/item bonus stored in low part
5159  SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus + val, perm_bonus));
5160 }
5161 
5162 // This functions sets a skill line value (and adds if doesn't exist yet)
5163 // To "remove" a skill line, set it's values to zero
5164 void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
5165 {
5166  if (!id)
5167  return;
5168 
5169  uint16 currVal;
5170  SkillStatusMap::iterator itr = mSkillStatus.find(id);
5171 
5172  //has skill
5173  if (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED)
5174  {
5175  currVal = SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)));
5176  if (newVal)
5177  {
5178  // if skill value is going down, update enchantments before setting the new value
5179  if (newVal < currVal)
5180  UpdateSkillEnchantments(id, currVal, newVal);
5181  // update step
5182  SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
5183  // update value
5184  SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(newVal, maxVal));
5185  if (itr->second.uState != SKILL_NEW)
5186  itr->second.uState = SKILL_CHANGED;
5187  learnSkillRewardedSpells(id, newVal);
5188  // if skill value is going up, update enchantments after setting the new value
5189  if (newVal > currVal)
5190  UpdateSkillEnchantments(id, currVal, newVal);
5193  }
5194  else //remove
5195  {
5196  //remove enchantments needing this skill
5197  UpdateSkillEnchantments(id, currVal, 0);
5198  // clear skill fields
5199  SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), 0);
5200  SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), 0);
5201  SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos), 0);
5202 
5203  // mark as deleted or simply remove from map if not saved yet
5204  if (itr->second.uState != SKILL_NEW)
5205  itr->second.uState = SKILL_DELETED;
5206  else
5207  mSkillStatus.erase(itr);
5208 
5209  // remove all spells that related to this skill
5210  for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
5211  if (SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j))
5212  if (pAbility->SkillLine == id)
5213  removeSpell(sSpellMgr->GetFirstSpellInChain(pAbility->Spell), SPEC_MASK_ALL, false);
5214  }
5215  }
5216  else if (newVal) //add
5217  {
5218  currVal = 0;
5219  for (int i = 0; i < PLAYER_MAX_SKILLS; ++i)
5221  {
5222  SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id);
5223  if (!pSkill)
5224  {
5225  LOG_ERROR("entities.player", "Skill not found in SkillLineStore: skill #%u", id);
5226  return;
5227  }
5228 
5231  UpdateSkillEnchantments(id, currVal, newVal);
5232 
5233  // insert new entry or update if not deleted old entry yet
5234  if (itr != mSkillStatus.end())
5235  {
5236  itr->second.pos = i;
5237  itr->second.uState = SKILL_CHANGED;
5238  }
5239  else
5240  mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
5241 
5242  // apply skill bonuses
5244 
5245  // temporary bonuses
5247  for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
5248  if ((*j)->GetMiscValue() == int32(id))
5249  (*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
5250 
5251  // permanent bonuses
5253  for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
5254  if ((*j)->GetMiscValue() == int32(id))
5255  (*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
5256 
5257  // Learn all spells for skill
5258  learnSkillRewardedSpells(id, newVal);
5261  return;
5262  }
5263  }
5264 }
5265 
5266 bool Player::HasSkill(uint32 skill) const
5267 {
5268  if (!skill)
5269  return false;
5270 
5271  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5272  return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED);
5273 }
5274 
5276 {
5277  if (!skill)
5278  return 0;
5279 
5280  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5281  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5282  return 0;
5283 
5284  return PAIR32_HIPART(GetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos)));
5285 }
5286 
5288 {
5289  if (!skill)
5290  return 0;
5291 
5292  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5293  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5294  return 0;
5295 
5296  uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos));
5297 
5298  int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
5299  result += SKILL_TEMP_BONUS(bonus);
5300  result += SKILL_PERM_BONUS(bonus);
5301  return result < 0 ? 0 : result;
5302 }
5303 
5305 {
5306  if (!skill)
5307  return 0;
5308 
5309  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5310  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5311  return 0;
5312 
5313  uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos));
5314 
5315  int32 result = int32(SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
5316  sScriptMgr->OnGetMaxSkillValue(const_cast<Player*>(this), skill, result, false);
5317  result += SKILL_TEMP_BONUS(bonus);
5318  result += SKILL_PERM_BONUS(bonus);
5319  return result < 0 ? 0 : result;
5320 }
5321 
5323 {
5324  if (!skill)
5325  return 0;
5326 
5327  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5328  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5329  return 0;
5330 
5331  int32 result = int32(SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
5332 
5333  sScriptMgr->OnGetMaxSkillValue(const_cast<Player*>(this), skill, result, true);
5334 
5335  return result < 0 ? 0 : result;
5336 }
5337 
5339 {
5340  if (!skill)
5341  return 0;
5342 
5343  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5344  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5345  return 0;
5346 
5347  int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))));
5348  result += SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
5349  return result < 0 ? 0 : result;
5350 }
5351 
5353 {
5354  if (!skill)
5355  return 0;
5356 
5357  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5358  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5359  return 0;
5360 
5361  return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)));
5362 }
5363 
5365 {
5366  if (!skill)
5367  return 0;
5368 
5369  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5370  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5371  return 0;
5372 
5373  return SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
5374 }
5375 
5377 {
5378  if (!skill)
5379  return 0;
5380 
5381  SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
5382  if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
5383  return 0;
5384 
5385  return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
5386 }
5387 
5389 {
5390  LOG_DEBUG("entities.player", "Sending Action Buttons for %s spec %u", GetGUID().ToString().c_str(), m_activeSpec);
5391 
5393  data << uint8(state);
5394  /*
5395  state can be 0, 1, 2
5396  0 - Looks to be sent when initial action buttons get sent, however on Trinity we use 1 since 0 had some difficulties
5397  1 - Used in any SMSG_ACTION_BUTTONS packet with button data on Trinity. Only used after spec swaps on retail.
5398  2 - Clears the action bars client sided. This is sent during spec swap before unlearning and before sending the new buttons
5399  */
5400  if (state != 2)
5401  {
5402  for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button)
5403  {
5404  ActionButtonList::const_iterator itr = m_actionButtons.find(button);
5405  if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED)
5406  data << uint32(itr->second.packedData);
5407  else
5408  data << uint32(0);
5409  }
5410  }
5411 
5412  GetSession()->SendPacket(&data);
5413  LOG_DEBUG("entities.player", "Action Buttons for %s spec %u Sent", GetGUID().ToString().c_str(), m_activeSpec);
5414 }
5415 
5417 {
5418  if (button >= MAX_ACTION_BUTTONS)
5419  {
5420  LOG_ERROR("entities.player", "Action %u not added into button %u for player %s: button must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTONS);
5421  return false;
5422  }
5423 
5424  if (action >= MAX_ACTION_BUTTON_ACTION_VALUE)
5425  {
5426  LOG_ERROR("entities.player", "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE);
5427  return false;
5428  }
5429 
5430  switch (type)
5431  {
5432  case ACTION_BUTTON_SPELL:
5433  if (!sSpellMgr->GetSpellInfo(action))
5434  {
5435  LOG_ERROR("entities.player", "Spell action %u not added into button %u for player %s: spell not exist", action, button, GetName().c_str());
5436  return false;
5437  }
5438 
5439  if (!HasSpell(action))
5440  {
5441  LOG_DEBUG("entities.player.loading", "Player::IsActionButtonDataValid Spell action %u not added into button %u for player %s: player don't known this spell", action, button, GetName().c_str());
5442  return false;
5443  }
5444  break;
5445  case ACTION_BUTTON_ITEM:
5446  if (!sObjectMgr->GetItemTemplate(action))
5447  {
5448  LOG_ERROR("entities.player", "Item action %u not added into button %u for player %s: item not exist", action, button, GetName().c_str());
5449  return false;
5450  }
5451  break;
5452  default:
5453  break; // other cases not checked at this moment
5454  }
5455 
5456  return true;
5457 }
5458 
5460 {
5461  if (!IsActionButtonDataValid(button, action, type))
5462  return nullptr;
5463 
5464  // it create new button (NEW state) if need or return existed
5465  ActionButton& ab = m_actionButtons[button];
5466 
5467  // set data and update to CHANGED if not NEW
5468  ab.SetActionAndType(action, ActionButtonType(type));
5469 
5470  LOG_DEBUG("entities.player", "Player %s Added Action %u (type %u) to Button %u", GetGUID().ToString().c_str(), action, type, button);
5471  return &ab;
5472 }
5473 
5475 {
5476  ActionButtonList::iterator buttonItr = m_actionButtons.find(button);
5477  if (buttonItr == m_actionButtons.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
5478  return;
5479 
5480  if (buttonItr->second.uState == ACTIONBUTTON_NEW)
5481  m_actionButtons.erase(buttonItr); // new and not saved
5482  else
5483  buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save
5484 
5485  LOG_DEBUG("entities.player", "Action Button %u Removed from Player %s", button, GetGUID().ToString().c_str());
5486 }
5487 
5489 {
5490  ActionButtonList::iterator buttonItr = m_actionButtons.find(button);
5491  if (buttonItr == m_actionButtons.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
5492  return nullptr;
5493 
5494  return &buttonItr->second;
5495 }
5496 
5498 {
5499  m_recallMap = GetMapId();
5500  m_recallX = GetPositionX();
5501  m_recallY = GetPositionY();
5502  m_recallZ = GetPositionZ();
5504 }
5505 
5506 // pussywizard!
5507 void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool includeMargin, Player const* skipped_rcvr)
5508 {
5509  if (self)
5510  GetSession()->SendPacket(data);
5511 
5512  dist += GetObjectSize();
5513  if (includeMargin)
5514  dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
5515  Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
5516  Cell::VisitWorldObjects(this, notifier, dist);
5517 }
5518 
5519 // pussywizard!
5520 void Player::SendMessageToSetInRange_OwnTeam(WorldPacket* data, float dist, bool self)
5521 {
5522  if (self)
5523  GetSession()->SendPacket(data);
5524 
5525  Acore::MessageDistDeliverer notifier(this, data, dist, true);
5526  Cell::VisitWorldObjects(this, notifier, dist);
5527 }
5528 
5530 {
5531  m_session->SendPacket(data);
5532 }
5533 
5534 void Player::SendCinematicStart(uint32 CinematicSequenceId)
5535 {
5537  data << uint32(CinematicSequenceId);
5538  SendDirectMessage(&data);
5539  if (const CinematicSequencesEntry* sequence = sCinematicSequencesStore.LookupEntry(CinematicSequenceId))
5540  {
5541  SetActiveCinematicCamera(sequence->cinematicCamera);
5542  }
5543 }
5544 
5546 {
5548  data << uint32(MovieId);
5549  SendDirectMessage(&data);
5550 }
5551 
5553 {
5554  if (!IsAlive())
5555  return;
5556 
5557  if (IsInFlight())
5558  return;
5559 
5560  bool isOutdoor = IsOutdoors();
5561  uint32 areaId = GetAreaId();
5562  AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
5563 
5564  if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK) && !isOutdoor)
5566 
5567  if (!sScriptMgr->CanAreaExploreAndOutdoor(this))
5568  return;
5569 
5570  if (!areaId)
5571  return;
5572 
5573  if (!areaEntry)
5574  {
5575  LOG_ERROR("entities.player", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)",
5576  GetName().c_str(), GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId());
5577  return;
5578  }
5579 
5580  uint32 offset = areaEntry->exploreFlag / 32;
5581 
5582  if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
5583  {
5584  LOG_ERROR("entities.player", "Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < %u ).", areaEntry->flags, GetPositionX(), GetPositionY(), offset, offset, PLAYER_EXPLORED_ZONES_SIZE);
5585  return;
5586  }
5587 
5588  uint32 val = (uint32)(1 << (areaEntry->exploreFlag % 32));
5589  uint32 currFields = GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
5590 
5591  if (!(currFields & val))
5592  {
5593  SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val));
5594 
5596 
5597  if (areaEntry->area_level > 0)
5598  {
5599  if (getLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
5600  {
5601  SendExplorationExperience(areaId, 0);
5602  }
5603  else
5604  {
5605  int32 diff = int32(getLevel()) - areaEntry->area_level;
5606  uint32 XP = 0;
5607  if (diff < -5)
5608  {
5609  XP = uint32(sObjectMgr->GetBaseXP(getLevel() + 5) * sWorld->getRate(RATE_XP_EXPLORE));
5610  }
5611  else if (diff > 5)
5612  {
5613  int32 exploration_percent = (100 - ((diff - 5) * 5));
5614  if (exploration_percent > 100)
5615  exploration_percent = 100;
5616  else if (exploration_percent < 0)
5617  exploration_percent = 0;
5618 
5619  XP = uint32(sObjectMgr->GetBaseXP(areaEntry->area_level) * exploration_percent / 100 * sWorld->getRate(RATE_XP_EXPLORE));
5620  }
5621  else
5622  {
5623  XP = uint32(sObjectMgr->GetBaseXP(areaEntry->area_level) * sWorld->getRate(RATE_XP_EXPLORE));
5624  }
5625 
5626  GiveXP(XP, nullptr);
5627  SendExplorationExperience(areaId, XP);
5628  }
5629  LOG_DEBUG("entities.player", "Player %s discovered a new area: %u", GetGUID().ToString().c_str(), areaId);
5630  }
5631  }
5632 }
5633 
5635 {
5636  if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race))
5637  {
5638  switch (rEntry->TeamID)
5639  {
5640  case 1:
5641  return TEAM_HORDE;
5642  case 7:
5643  return TEAM_ALLIANCE;
5644  }
5645  LOG_ERROR("entities.player", "Race (%u) has wrong teamid (%u) in DBC: wrong DBC files?", uint32(race), rEntry->TeamID);
5646  }
5647  else
5648  LOG_ERROR("entities.player", "Race (%u) not found in DBC: wrong DBC files?", uint32(race));
5649 
5650  return TEAM_ALLIANCE;
5651 }
5652 
5654 {
5655  m_team = TeamIdForRace(race);
5656 
5657  sScriptMgr->OnPlayerUpdateFaction(this);
5658 
5659  if (GetTeamId(true) != GetTeamId())
5660  return;
5661 
5662  ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
5663  SetFaction(rEntry ? rEntry->FactionID : 0);
5664 }
5665 
5667 {
5668  FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
5669  return GetReputationMgr().GetRank(factionEntry);
5670 }
5671 
5672 // Calculate total reputation percent player gain with quest/creature level
5673 int32 Player::CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus)
5674 {
5675  float percent = 100.0f;
5676 
5677  float repMod = noQuestBonus ? 0.0f : float(GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
5678 
5679  // faction specific auras only seem to apply to kills
5680  if (source == REPUTATION_SOURCE_KILL)
5682 
5683  percent += rep > 0 ? repMod : -repMod;
5684 
5685  float rate;
5686  switch (source)
5687  {
5689  rate = sWorld->getRate(RATE_REPUTATION_LOWLEVEL_KILL);
5690  break;
5696  rate = sWorld->getRate(RATE_REPUTATION_LOWLEVEL_QUEST);
5697  break;
5699  default:
5700  rate = 1.0f;
5701  break;
5702  }
5703 
5704  if (rate != 1.0f && creatureOrQuestLevel <= Acore::XP::GetGrayLevel(getLevel()))
5705  percent *= rate;
5706 
5707  if (percent <= 0.0f)
5708  return 0;
5709 
5710  // Multiply result with the faction specific rate
5711  if (RepRewardRate const* repData = sObjectMgr->GetRepRewardRate(faction))
5712  {
5713  float repRate = 0.0f;
5714  switch (source)
5715  {
5717  repRate = repData->creatureRate;
5718  break;
5720  repRate = repData->questRate;
5721  break;
5723  repRate = repData->questDailyRate;
5724  break;
5726  repRate = repData->questWeeklyRate;
5727  break;
5729  repRate = repData->questMonthlyRate;
5730  break;
5732  repRate = repData->questRepeatableRate;
5733  break;
5735  repRate = repData->spellRate;
5736  break;
5737  }
5738 
5739  // for custom, a rate of 0.0 will totally disable reputation gain for this faction/type
5740  if (repRate <= 0.0f)
5741  return 0;
5742 
5743  percent *= repRate;
5744  }
5745 
5746  if (source != REPUTATION_SOURCE_SPELL && GetsRecruitAFriendBonus(false))
5747  percent *= 1.0f + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS);
5748 
5749  return CalculatePct(rep, percent);
5750 }
5751 
5752 // Calculates how many reputation points player gains in victim's enemy factions
5753 void Player::RewardReputation(Unit* victim, float rate)
5754 {
5755  if (!victim || victim->GetTypeId() == TYPEID_PLAYER)
5756  return;
5757 
5758  if (victim->ToCreature()->IsReputationGainDisabled())
5759  return;
5760 
5761  ReputationOnKillEntry const* Rep = sObjectMgr->GetReputationOnKilEntry(victim->ToCreature()->GetCreatureTemplate()->Entry);
5762  if (!Rep)
5763  return;
5764 
5765  uint32 ChampioningFaction = 0;
5766 
5767  if (GetChampioningFaction())
5768  {
5769  // support for: Championing - http://www.wowwiki.com/Championing
5770  Map const* map = GetMap();
5771  if (map->IsNonRaidDungeon())
5772  if (LFGDungeonEntry const* dungeon = GetLFGDungeon(map->GetId(), map->GetDifficulty()))
5773  if (dungeon->reclevel == 80)
5774  ChampioningFaction = GetChampioningFaction();
5775  }
5776 
5777  TeamId teamId = GetTeamId(true); // Always check player original reputation when rewarding
5778 
5779  if (Rep->RepFaction1 && (!Rep->TeamDependent || teamId == TEAM_ALLIANCE))
5780  {
5781  int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
5782  donerep1 = int32(donerep1 * rate);
5783 
5784  FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
5785  uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
5786  if (factionEntry1)
5787  GetReputationMgr().ModifyReputation(factionEntry1, donerep1, bool(current_reputation_rank1 > Rep->ReputationMaxCap1));
5788  }
5789 
5790  if (Rep->RepFaction2 && (!Rep->TeamDependent || teamId == TEAM_HORDE))
5791  {
5792  int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue2, ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
5793  donerep2 = int32(donerep2 * rate);
5794 
5795  FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
5796  uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
5797  if (factionEntry2)
5798  GetReputationMgr().ModifyReputation(factionEntry2, donerep2, bool(current_reputation_rank2 > Rep->ReputationMaxCap2));
5799  }
5800 }
5801 
5802 // Calculate how many reputation points player gain with the quest
5804 {
5805  for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
5806  {
5807  if (!quest->RewardFactionId[i])
5808  continue;
5809 
5810  int32 rep = 0;
5811 
5812  if (quest->RewardFactionValueIdOverride[i])
5813  {
5814  rep = quest->RewardFactionValueIdOverride[i] / 100;
5815  }
5816  else
5817  {
5818  uint32 row = ((quest->RewardFactionValueId[i] < 0) ? 1 : 0) + 1;
5819  if (QuestFactionRewEntry const* questFactionRewEntry = sQuestFactionRewardStore.LookupEntry(row))
5820  {
5821  uint32 field = abs(quest->RewardFactionValueId[i]);
5822  rep = questFactionRewEntry->QuestRewFactionValue[field];
5823  }
5824  }
5825 
5826  if (!rep)
5827  continue;
5828 
5829  if (quest->IsDaily())
5830  {
5832  }
5833  else if (quest->IsWeekly())
5834  {
5836  }
5837  else if (quest->IsMonthly())
5838  {
5840  }
5841  else if (quest->IsRepeatable())
5842  {
5844  }
5845  else
5846  {
5847  rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
5848  }
5849 
5850  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
5851  GetReputationMgr().ModifyReputation(factionEntry, rep);
5852  }
5853 }
5854 
5856 {
5857  if (bonusTalentPoints)
5858  {
5859  m_extraBonusTalentCount += bonusTalentPoints;
5860  }
5861 }
5862 
5866 bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awardXP)
5867 {
5868  // do not reward honor in arenas, but enable onkill spellproc
5869  if (InArena())
5870  {
5871  if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER)
5872  return false;
5873 
5874  if (GetBgTeamId() == uVictim->ToPlayer()->GetBgTeamId())
5875  return false;
5876 
5877  return true;
5878  }
5879 
5880  // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
5882  return false;
5883 
5884  /* check if player has same IP
5885  if (uVictim && uVictim->GetTypeId() == TYPEID_PLAYER)
5886  {
5887  if (GetSession()->GetRemoteAddress() == uVictim->ToPlayer()->GetSession()->GetRemoteAddress())
5888  return false;
5889  }
5890  */
5891 
5892  ObjectGuid victim_guid;
5893  uint32 victim_rank = 0;
5894 
5895  // need call before fields update to have chance move yesterday data to appropriate fields before today data change.
5897 
5898  // do not reward honor in arenas, but return true to enable onkill spellproc
5899  if (InArena())
5900  return true;
5901 
5902  // Promote to float for calculations
5903  float honor_f = (float)honor;
5904 
5905  if (honor_f <= 0)
5906  {
5907  if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT))
5908  return false;
5909 
5910  victim_guid = uVictim->GetGUID();
5911 
5912  if (uVictim->GetTypeId() == TYPEID_PLAYER)
5913  {
5914  Player* victim = uVictim->ToPlayer();
5915 
5916  if (GetTeamId() == victim->GetTeamId() && !sWorld->IsFFAPvPRealm())
5917  return false;
5918 
5919  uint8 k_level = getLevel();
5920  uint8 k_grey = Acore::XP::GetGrayLevel(k_level);
5921  uint8 v_level = victim->getLevel();
5922 
5923  if (v_level <= k_grey)
5924  return false;
5925 
5926  // PLAYER_CHOSEN_TITLE VALUES DESCRIPTION
5927  // [0] Just name
5928  // [1..14] Alliance honor titles and player name
5929  // [15..28] Horde honor titles and player name
5930  // [29..38] Other title and player name
5931  // [39+] Nothing
5932  uint32 victim_title = victim->GetUInt32Value(PLAYER_CHOSEN_TITLE);
5933  uint32 killer_title = 0;
5934  sScriptMgr->OnVictimRewardBefore(this, victim, killer_title, victim_title);
5935  // Get Killer titles, CharTitlesEntry::bit_index
5936  // Ranks:
5937  // title[1..14] -> rank[5..18]
5938  // title[15..28] -> rank[5..18]
5939  // title[other] -> 0
5940  if (victim_title == 0)
5941  victim_guid.Clear(); // Don't show HK: <rank> message, only log.
5942  else if (victim_title < 15)
5943  victim_rank = victim_title + 4;
5944  else if (victim_title < 29)
5945  victim_rank = victim_title - 14 + 4;
5946  else
5947  victim_guid.Clear(); // Don't show HK: <rank> message, only log.
5948 
5949  honor_f = ceil(Acore::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
5950 
5951  // count the number of playerkills in one day
5953  // and those in a lifetime
5961  sScriptMgr->OnVictimRewardAfter(this, victim, killer_title, victim_rank, honor_f);
5962  }
5963  else
5964  {
5965  if (!uVictim->ToCreature()->IsRacialLeader())
5966  return false;
5967 
5968  honor_f = 100.0f; // ??? need more info
5969  victim_rank = 19; // HK: Leader
5970  }
5971  }
5972 
5973  if (uVictim != nullptr)
5974  {
5975  if (groupsize > 1)
5976  honor_f /= groupsize;
5977 
5978  // apply honor multiplier from aura (not stacking-get highest)
5980  }
5981 
5982  honor_f *= sWorld->getRate(RATE_HONOR);
5983  // Back to int now
5984  honor = int32(honor_f);
5985  // honor - for show honor points in log
5986  // victim_guid - for show victim name in log
5987  // victim_rank [1..4] HK: <dishonored rank>
5988  // victim_rank [5..19] HK: <alliance\horde rank>
5989  // victim_rank [0, 20+] HK: <>
5990  WorldPacket data(SMSG_PVP_CREDIT, 4 + 8 + 4);
5991  data << honor;
5992  data << victim_guid;
5993  data << victim_rank;
5994 
5995  // Xinef: non quest case, quest honor obtain is send in quest reward packet
5996  if (uVictim || groupsize > 0)
5997  GetSession()->SendPacket(&data);
5998 
5999  // add honor points
6000  ModifyHonorPoints(honor);
6001 
6003 
6004  // Xinef: Battleground experience
6005  if (awardXP)
6006  if (Battleground* bg = GetBattleground())
6007  {
6008  bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, honor, false); //false: prevent looping
6009  // Xinef: Only for BG activities
6010  if (!uVictim)
6011  GiveXP(uint32(honor * (3 + getLevel() * 0.30f)), nullptr);
6012  }
6013 
6014  if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE))
6015  {
6016  if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT))
6017  return true;
6018 
6019  if (uVictim->GetTypeId() == TYPEID_PLAYER)
6020  {
6021  // Check if allowed to receive it in current map
6022  uint8 MapType = sWorld->getIntConfig(CONFIG_PVP_TOKEN_MAP_TYPE);
6023  if ((MapType == 1 && !InBattleground() && !IsFFAPvP())
6024  || (MapType == 2 && !IsFFAPvP())
6025  || (MapType == 3 && !InBattleground()))
6026  return true;
6027 
6028  uint32 itemID = sWorld->getIntConfig(CONFIG_PVP_TOKEN_ID);
6029  int32 count = sWorld->getIntConfig(CONFIG_PVP_TOKEN_COUNT);
6030 
6031  if (AddItem(itemID, count))
6032  ChatHandler(GetSession()).PSendSysMessage("You have been awarded a token for slaying another player.");
6033  }
6034  }
6035 
6036  return true;
6037 }
6038 
6040 {
6041  if (value > sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS))
6042  value = sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS);
6044  if (value)
6046 }
6047 
6049 {
6050  if (value > sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS))
6051  value = sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS);
6053  if (value)
6055 }
6056 
6058 {
6059  int32 newValue = int32(GetHonorPoints()) + value;
6060  if (newValue < 0)
6061  newValue = 0;
6062  SetHonorPoints(uint32(newValue));
6063 
6064  if (trans)
6065  {
6067  stmt->setUInt32(0, newValue);
6068  stmt->setUInt32(1, GetGUID().GetCounter());
6069  trans->Append(stmt);
6070  }
6071 }
6072 
6074 {
6075  int32 newValue = int32(GetArenaPoints()) + value;
6076  if (newValue < 0)
6077  newValue = 0;
6078  SetArenaPoints(uint32(newValue));
6079 
6080  if (trans)
6081  {
6083  stmt->setUInt32(0, newValue);
6084  stmt->setUInt32(1, GetGUID().GetCounter());
6085  trans->Append(stmt);
6086  }
6087 }
6088 
6090 {
6091  if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid))
6092  return playerData->guildId;
6093  return 0;
6094 }
6095 
6097 {
6098  if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid))
6099  return playerData->groupId;
6100  return 0;
6101 }
6102 
6104 {
6105  if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid))
6106  {
6107  auto itr = playerData->arenaTeamId.find(slot);
6108  if (itr != playerData->arenaTeamId.end())
6109  {
6110  return itr->second;
6111  }
6112  }
6113  return 0;
6114 }
6115 
6117 {
6119  stmt->setUInt32(0, guid.GetCounter());
6120  stmt->setUInt8(1, type);
6121  PreparedQueryResult result = CharacterDatabase.Query(stmt);
6122 
6123  if (!result)
6124  return 0;
6125 
6126  uint32 id = (*result)[0].GetUInt32();
6127  return id;
6128 }
6129 
6131 {
6132  ObjectGuid::LowType guidLow = guid.GetCounter();
6133 
6135  stmt->setUInt32(0, guidLow);
6136  PreparedQueryResult result = CharacterDatabase.Query(stmt);
6137 
6138  if (!result)
6139  return 0;
6140 
6141  Field* fields = result->Fetch();
6142  uint32 zone = fields[0].GetUInt16();
6143 
6144  if (!zone)
6145  {
6146  // stored zone is zero, use generic and slow zone detection
6147  stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_POSITION_XYZ);
6148  stmt->setUInt32(0, guidLow);
6149  PreparedQueryResult posResult = CharacterDatabase.Query(stmt);
6150 
6151  if (!posResult)
6152  {
6153  return 0;
6154  }
6155 
6156  fields = posResult->Fetch();
6157  uint32 map = fields[0].GetUInt16();
6158  float posx = fields[1].GetFloat();
6159  float posy = fields[2].GetFloat();
6160  float posz = fields[3].GetFloat();
6161 
6162  if (!sMapStore.LookupEntry(map))
6163  return 0;
6164 
6165  zone = sMapMgr->GetZoneId(PHASEMASK_NORMAL, map, posx, posy, posz);
6166 
6167  if (zone > 0)
6168  {
6169  stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ZONE);
6170 
6171  stmt->setUInt16(0, uint16(zone));
6172  stmt->setUInt32(1, guidLow);
6173 
6174  CharacterDatabase.Execute(stmt);
6175  }
6176  }
6177 
6178  return zone;
6179 }
6180 
6182 {
6183  // xinef: Get data from global storage
6184  if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid))
6185  return playerData->level;
6186 
6187  return 0;
6188 }
6189 
6190 //If players are too far away from the duel flag... they lose the duel
6191 void Player::CheckDuelDistance(time_t currTime)
6192 {
6193  if (!duel)
6194  return;
6195 
6197  GameObject* obj = GetMap()->GetGameObject(duelFlagGUID);
6198  if (!obj)
6199  return;
6200 
6201  if (duel->outOfBound == 0)
6202  {
6203  if (!IsWithinDistInMap(obj, 50))
6204  {
6205  duel->outOfBound = currTime;
6206 
6208  GetSession()->SendPacket(&data);
6209  }
6210  }
6211  else
6212  {
6213  if (IsWithinDistInMap(obj, 40))
6214  {
6215  duel->outOfBound = 0;
6216 
6218  GetSession()->SendPacket(&data);
6219  }
6220  else if (currTime >= (duel->outOfBound + 10))
6222  }
6223 }
6224 
6226 {
6228 }
6229 
6231 {
6232  // duel not requested
6233  if (!duel || !duel->opponent || !duel->initiator)
6234  return;
6235 
6236  LOG_DEBUG("entities.unit", "Duel Complete %s %s", GetName().c_str(), duel->opponent->GetName().c_str());
6237 
6238  WorldPacket data(SMSG_DUEL_COMPLETE, (1));
6239  data << (uint8)((type != DUEL_INTERRUPTED) ? 1 : 0);
6240  GetSession()->SendPacket(&data);
6241 
6242  duel->opponent->GetSession()->SendPacket(&data);
6243 
6244  if (type != DUEL_INTERRUPTED)
6245  {
6246  data.Initialize(SMSG_DUEL_WINNER, (1 + 20)); // we guess size
6247  data << uint8(type == DUEL_WON ? 0 : 1); // 0 = just won; 1 = fled
6248  data << duel->opponent->GetName();
6249  data << GetName();
6250  SendMessageToSet(&data, true);
6251  }
6252 
6253  sScriptMgr->OnPlayerDuelEnd(duel->opponent, this, type);
6254 
6255  switch (type)
6256  {
6257  case DUEL_FLED:
6258  // if initiator and opponent are on the same team
6259  // or initiator and opponent are not PvP enabled, forcibly stop attacking
6260  if (duel->initiator->GetTeamId() == duel->opponent->GetTeamId())
6261  {
6263  duel->opponent->AttackStop();
6264  }
6265  else
6266  {
6267  if (!duel->initiator->IsPvP())
6269  if (!duel->opponent->IsPvP())
6270  duel->opponent->AttackStop();
6271  }
6272  break;
6273  case DUEL_WON:
6276 
6277  // Credit for quest Death's Challenge
6279  duel->opponent->CastSpell(duel->opponent, 52994, true);
6280 
6281  // Honor points after duel (the winner) - ImpConfig
6282  if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
6283  duel->opponent->RewardHonor(nullptr, 1, amount);
6284 
6285  break;
6286  default:
6287  break;
6288  }
6289 
6290  // Victory emote spell
6291  if (type != DUEL_INTERRUPTED && duel->opponent)
6292  duel->opponent->CastSpell(duel->opponent, 52852, true);
6293 
6294  //Remove Duel Flag object
6296  if (obj)
6297  duel->initiator->RemoveGameObject(obj, true);
6298 
6299  /* remove auras */
6301  for (AuraApplicationMap::iterator i = itsAuras.begin(); i != itsAuras.end();)
6302  {
6303  Aura const* aura = i->second->GetBase();
6304  if (!i->second->IsPositive() && aura->GetCasterGUID() == GetGUID() && aura->GetApplyTime() >= duel->startTime)
6305  duel->opponent->RemoveAura(i);
6306  else
6307  ++i;
6308  }
6309 
6310  AuraApplicationMap& myAuras = GetAppliedAuras();
6311  for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();)
6312  {
6313  Aura const* aura = i->second->GetBase();
6314  if (!i->second->IsPositive() && aura->GetCasterGUID() == duel->opponent->GetGUID() && aura->GetApplyTime() >= duel->startTime)
6315  RemoveAura(i);
6316  else
6317  ++i;
6318  }
6319 
6320  // cleanup combo points
6321  if (GetComboTarget() == duel->opponent->GetGUID())
6322  ClearComboPoints();
6323  else if (GetComboTarget() == duel->opponent->GetPetGUID())
6324  ClearComboPoints();
6325 
6326  if (duel->opponent->GetComboTarget() == GetGUID())
6328  else if (duel->opponent->GetComboTarget() == GetPetGUID())
6330 
6331  //cleanups
6336 
6337  delete duel->opponent->duel;
6338  duel->opponent->duel = nullptr;
6339  delete duel;
6340  duel = nullptr;
6341 }
6342 
6343 //---------------------------------------------------------//
6344 
6345 void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply)
6346 {
6347  if (slot >= INVENTORY_SLOT_BAG_END || !item)
6348  return;
6349 
6350  ItemTemplate const* proto = item->GetTemplate();
6351 
6352  if (!proto)
6353  return;
6354 
6355  // not apply/remove mods for broken item
6356  if (item->IsBroken())
6357  return;
6358 
6359  LOG_DEBUG("entities.player", "applying mods for item %s ", item->GetGUID().ToString().c_str());
6360 
6361  uint8 attacktype = Player::GetAttackBySlot(slot);
6362 
6363  if (item->HasSocket()) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items
6365 
6366  if (attacktype < MAX_ATTACK)
6368 
6369  _ApplyItemBonuses(proto, slot, apply);
6370 
6371  if (slot == EQUIPMENT_SLOT_RANGED)
6373 
6374  ApplyItemEquipSpell(item, apply);
6375  ApplyEnchantment(item, apply);
6376 
6377  LOG_DEBUG("entities.player.items", "_ApplyItemMods complete.");
6378 }
6379 
6380 void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply, bool only_level_scale /*= false*/)
6381 {
6382  if (slot >= INVENTORY_SLOT_BAG_END || !proto)
6383  return;
6384 
6386  if (only_level_scale && !ssd)
6387  return;
6388 
6389  // req. check at equip, but allow use for extended range if range limit max level, set proper level
6390  uint32 ssd_level = getLevel();
6391  uint32 CustomScalingStatValue = 0;
6392 
6393  sScriptMgr->OnCustomScalingStatValueBefore(this, proto, slot, apply, CustomScalingStatValue);
6394 
6395  uint32 ScalingStatValue = proto->ScalingStatValue > 0 ? proto->ScalingStatValue : CustomScalingStatValue;
6396 
6397  if (ssd && ssd_level > ssd->MaxLevel)
6398  ssd_level = ssd->MaxLevel;
6399 
6400  ScalingStatValuesEntry const* ssv = proto->ScalingStatValue ? sScalingStatValuesStore.LookupEntry(ssd_level) : nullptr;
6401  if (only_level_scale && !ssv)
6402  return;
6403 
6404  for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
6405  {
6406  uint32 statType = 0;
6407  int32 val = 0;
6408  // If set ScalingStatDistribution need get stats and values from it
6409  if (ssv)
6410  {
6411  if (ssd)
6412  {
6413  if (ssd->StatMod[i] < 0)
6414  continue;
6415 
6416  statType = ssd->StatMod[i];
6417  val = (ssv->getssdMultiplier(ScalingStatValue) * ssd->Modifier[i]) / 10000;
6418  }
6419  else
6420  {
6421  if (i >= proto->StatsCount)
6422  continue;
6423 
6424  // OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv)
6425  sScriptMgr->OnCustomScalingStatValue(this, proto, statType, val, i, ScalingStatValue, ssv);
6426  }
6427  }
6428  else
6429  {
6430  if (i >= proto->StatsCount)
6431  continue;
6432 
6433  statType = proto->ItemStat[i].ItemStatType;
6434  val = proto->ItemStat[i].ItemStatValue;
6435  }
6436 
6437  if (val == 0)
6438  continue;
6439 
6440  switch (statType)
6441  {
6442  case ITEM_MOD_MANA:
6444  break;
6445  case ITEM_MOD_HEALTH: // modify HP
6447  break;
6448  case ITEM_MOD_AGILITY: // modify agility
6450  ApplyStatBuffMod(STAT_AGILITY, float(val), apply);
6451  break;
6452  case ITEM_MOD_STRENGTH: //modify strength
6454  ApplyStatBuffMod(STAT_STRENGTH, float(val), apply);
6455  break;
6456  case ITEM_MOD_INTELLECT: //modify intellect
6458  ApplyStatBuffMod(STAT_INTELLECT, float(val), apply);
6459  break;
6460  case ITEM_MOD_SPIRIT: //modify spirit
6462  ApplyStatBuffMod(STAT_SPIRIT, float(val), apply);
6463  break;
6464  case ITEM_MOD_STAMINA: //modify stamina
6466  ApplyStatBuffMod(STAT_STAMINA, float(val), apply);
6467  break;
6470  break;
6471  case ITEM_MOD_DODGE_RATING:
6473  break;
6474  case ITEM_MOD_PARRY_RATING:
6476  break;
6477  case ITEM_MOD_BLOCK_RATING:
6479  break;
6482  break;
6485  break;
6488  break;
6491  break;
6494  break;
6497  break;
6500  break;
6503  break;
6506  break;
6509  break;
6512  break;
6515  break;
6518  break;
6521  break;
6524  break;
6525  case ITEM_MOD_HIT_RATING:
6529  break;
6530  case ITEM_MOD_CRIT_RATING:
6534  break;
6539  break;
6545  break;
6546  case ITEM_MOD_HASTE_RATING:
6550  break;
6553  break;
6554  case ITEM_MOD_ATTACK_POWER:
6557  break;
6560  break;
6561  // case ITEM_MOD_FERAL_ATTACK_POWER:
6562  // ApplyFeralAPBonus(int32(val), apply);
6563  // break;
6566  break;
6569  break;
6570  case ITEM_MOD_SPELL_POWER:
6572  break;
6573  case ITEM_MOD_HEALTH_REGEN:
6575  break;
6578  break;
6579  case ITEM_MOD_BLOCK_VALUE:
6581  break;
6582  // deprecated item mods
6585  break;
6586  }
6587  }
6588 
6589  // Apply Spell Power from ScalingStatValue if set
6590  if (ssv)
6591  if (int32 spellbonus = ssv->getSpellBonus(ScalingStatValue))
6592  ApplySpellPowerBonus(spellbonus, apply);
6593 
6594  // If set ScalingStatValue armor get it or use item armor
6595  uint32 armor = proto->Armor;
6596  if (ssv)
6597  {
6598  if (uint32 ssvarmor = ssv->getArmorMod(ScalingStatValue))
6599  if (proto->ScalingStatValue > 0 || ssvarmor < proto->Armor) //Check to avoid higher values than stat itself (heirloom OR items with correct armor value)
6600  armor = ssvarmor;
6601  }
6602  else if (armor && proto->ArmorDamageModifier)
6603  armor -= uint32(proto->ArmorDamageModifier);
6604 
6605  if (armor)
6606  {
6607  UnitModifierType modType = TOTAL_VALUE;
6608  if (proto->Class == ITEM_CLASS_ARMOR)
6609  {
6610  switch (proto->SubClass)
6611  {
6617  modType = BASE_VALUE;
6618  break;
6619  }
6620  }
6621  HandleStatModifier(UNIT_MOD_ARMOR, modType, float(armor), apply);
6622  }
6623 
6624  // Add armor bonus from ArmorDamageModifier if > 0
6625  if (proto->ArmorDamageModifier > 0 && sScriptMgr->CanArmorDamageModifier(this))
6627 
6628  if (proto->Block)
6630 
6631  if (proto->HolyRes)
6633 
6634  if (proto->FireRes)
6636 
6637  if (proto->NatureRes)
6639 
6640  if (proto->FrostRes)
6642 
6643  if (proto->ShadowRes)
6645 
6646  if (proto->ArcaneRes)
6648 
6649  WeaponAttackType attType = BASE_ATTACK;
6650 
6651  if (slot == EQUIPMENT_SLOT_RANGED && (
6652  proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN ||
6654  {
6655  attType = RANGED_ATTACK;
6656  }
6657  else if (slot == EQUIPMENT_SLOT_OFFHAND)
6658  {
6659  attType = OFF_ATTACK;
6660  }
6661 
6662  if (CanUseAttackType(attType))
6663  _ApplyWeaponDamage(slot, proto, ssv, apply);
6664 
6665  // Druids get feral AP bonus from weapon dps (also use DPS from ScalingStatValue)
6666  if (getClass() == CLASS_DRUID)
6667  {
6668  int32 dpsMod = 0;
6669  int32 feral_bonus = 0;
6670  if (ssv)
6671  {
6672  dpsMod = ssv->getDPSMod(ScalingStatValue);
6673  feral_bonus += ssv->getFeralBonus(ScalingStatValue);
6674  }
6675 
6676  feral_bonus += proto->getFeralBonus(dpsMod);
6677  sScriptMgr->OnGetFeralApBonus(this, feral_bonus, dpsMod, proto, ssv);
6678  if (feral_bonus)
6679  ApplyFeralAPBonus(feral_bonus, apply);
6680  }
6681 }
6682 
6684 {
6685  uint32 CustomScalingStatValue = 0;
6686 
6687  sScriptMgr->OnCustomScalingStatValueBefore(this, proto, slot, apply, CustomScalingStatValue);
6688 
6689  uint32 ScalingStatValue = proto->ScalingStatValue > 0 ? proto->ScalingStatValue : CustomScalingStatValue;
6690 
6691  // following part fix disarm issue
6692  // that doesn't apply the scaling after disarmed
6693  if (!ssv)
6694  {
6696 
6697  // req. check at equip, but allow use for extended range if range limit max level, set proper level
6698  uint32 ssd_level = getLevel();
6699 
6700  if (ssd && ssd_level > ssd->MaxLevel)
6701  ssd_level = ssd->MaxLevel;
6702 
6703  ssv = ScalingStatValue ? sScalingStatValuesStore.LookupEntry(ssd_level) : nullptr;
6704  }
6705 
6706  WeaponAttackType attType = BASE_ATTACK;
6707  float damage = 0.0f;
6708 
6709  if (slot == EQUIPMENT_SLOT_RANGED && (
6710  proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN ||
6712  {
6713  attType = RANGED_ATTACK;
6714  }
6715  else if (slot == EQUIPMENT_SLOT_OFFHAND)
6716  {
6717  attType = OFF_ATTACK;
6718  }
6719 
6720  float minDamage = proto->Damage[0].DamageMin;
6721  float maxDamage = proto->Damage[0].DamageMax;
6722 
6723  // If set dpsMod in ScalingStatValue use it for min (70% from average), max (130% from average) damage
6724  if (ssv)
6725  {
6726  int32 extraDPS = ssv->getDPSMod(ScalingStatValue);
6727  if (extraDPS)
6728  {
6729  float average = extraDPS * proto->Delay / 1000.0f;
6730  minDamage = 0.7f * average;
6731  maxDamage = 1.3f * average;
6732  }
6733  }
6734 
6735  if (minDamage > 0)
6736  {
6737  damage = apply ? minDamage : BASE_MINDAMAGE;
6738  SetBaseWeaponDamage(attType, MINDAMAGE, damage);
6739  }
6740 
6741  if (maxDamage > 0)
6742  {
6743  damage = apply ? maxDamage : BASE_MAXDAMAGE;
6744  SetBaseWeaponDamage(attType, MAXDAMAGE, damage);
6745  }
6746 
6747  if (proto->Delay && !IsInFeralForm())
6748  {
6749  if (slot == EQUIPMENT_SLOT_RANGED)
6751  else if (slot == EQUIPMENT_SLOT_MAINHAND)
6753  else if (slot == EQUIPMENT_SLOT_OFFHAND)
6755  }
6756 
6757  // No need to modify any physical damage for ferals as it is calculated from stats only
6758  if (IsInFeralForm())
6759  return;
6760 
6761  if (CanModifyStats() && (damage || proto->Delay))
6762  UpdateDamagePhysical(attType);
6763 }
6764 
6766 {
6768  for (AuraEffectList::const_iterator itr = auraCritList.begin(); itr != auraCritList.end(); ++itr)
6769  _ApplyWeaponDependentAuraCritMod(item, attackType, *itr, apply);
6770 
6771  AuraEffectList const& auraDamageFlatList = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
6772  for (AuraEffectList::const_iterator itr = auraDamageFlatList.begin(); itr != auraDamageFlatList.end(); ++itr)
6773  _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
6774 
6776  for (AuraEffectList::const_iterator itr = auraDamagePctList.begin(); itr != auraDamagePctList.end(); ++itr)
6777  _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
6778 }
6779 
6781 {
6782  // don't apply mod if item is broken or cannot be used
6783  if (item->IsBroken() || !CanUseAttackType(attackType))
6784  return;
6785 
6786  // generic not weapon specific case processes in aura code
6787  if (aura->GetSpellInfo()->EquippedItemClass == -1)
6788  return;
6789 
6790  if (!sScriptMgr->CanApplyWeaponDependentAuraDamageMod(this, item, attackType, aura, apply))
6791  return;
6792 
6793  BaseModGroup mod = BASEMOD_END;
6794  switch (attackType)
6795  {
6796  case BASE_ATTACK:
6797  mod = CRIT_PERCENTAGE;
6798  break;
6799  case OFF_ATTACK:
6801  break;
6802  case RANGED_ATTACK:
6803  mod = RANGED_CRIT_PERCENTAGE;
6804  break;
6805  default:
6806  return;
6807  }
6808 
6809  if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
6810  HandleBaseModValue(mod, FLAT_MOD, float (aura->GetAmount()), apply);
6811 }
6812 
6814 {
6815  // don't apply mod if item is broken or cannot be used
6816  if (item->IsBroken() || !CanUseAttackType(attackType))
6817  return;
6818 
6819  // ignore spell mods for not wands
6820  if ((aura->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) == 0 && (getClassMask() & CLASSMASK_WAND_USERS) == 0)
6821  return;
6822 
6823  // generic not weapon specific case processes in aura code
6824  if (aura->GetSpellInfo()->EquippedItemClass == -1)
6825  return;
6826 
6827  UnitMods unitMod = UNIT_MOD_END;
6828  switch (attackType)
6829  {
6830  case BASE_ATTACK:
6831  unitMod = UNIT_MOD_DAMAGE_MAINHAND;
6832  break;
6833  case OFF_ATTACK:
6834  unitMod = UNIT_MOD_DAMAGE_OFFHAND;
6835  break;
6836  case RANGED_ATTACK:
6837  unitMod = UNIT_MOD_DAMAGE_RANGED;
6838  break;
6839  default:
6840  return;
6841  }
6842 
6843  UnitModifierType unitModType = TOTAL_VALUE;
6844  switch (aura->GetAuraType())
6845  {
6847  unitModType = TOTAL_VALUE;
6848  break;
6850  unitModType = TOTAL_PCT;
6851  break;
6852  default:
6853  return;
6854  }
6855 
6856  if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
6857  {
6858  HandleStatModifier(unitMod, unitModType, float(aura->GetAmount()), apply);
6859  if (unitModType == TOTAL_VALUE)
6860  {
6861  if (aura->GetAmount() > 0)
6863  else
6865  }
6866  }
6867 }
6868 
6869 void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change)
6870 {
6871  if (!item)
6872  return;
6873 
6874  ItemTemplate const* proto = item->GetTemplate();
6875  if (!proto)
6876  return;
6877 
6878  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
6879  {
6880  _Spell const& spellData = proto->Spells[i];
6881 
6882  // no spell
6883  if (!spellData.SpellId)
6884  continue;
6885 
6886  // Spells that should stay on the caster after removing the item.
6887  constexpr std::array<uint32, 1> spellExceptions = { /*Electromagnetic Gigaflux Reactivator*/ 11826 };
6888  const auto found = std::find(std::begin(spellExceptions), std::end(spellExceptions), spellData.SpellId);
6889 
6890  // wrong triggering type
6891  if (apply)
6892  {
6893  if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
6894  {
6895  continue;
6896  }
6897  }
6898  else
6899  {
6900  // If the spell is an exception do not remove it.
6901  if (found != std::end(spellExceptions))
6902  {
6903  continue;
6904  }
6905  }
6906 
6907  // check if it is valid spell
6908  SpellInfo const* spellproto = sSpellMgr->GetSpellInfo(spellData.SpellId);
6909  if (!spellproto)
6910  continue;
6911 
6912  ApplyEquipSpell(spellproto, item, apply, form_change);
6913  }
6914 }
6915 
6916 void Player::ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, bool form_change)
6917 {
6918  if (apply)
6919  {
6920  if (!sScriptMgr->CanApplyEquipSpell(this, spellInfo, item, apply, form_change))
6921  return;
6922 
6923  // Cannot be used in this stance/form
6924  if (spellInfo->CheckShapeshift(GetShapeshiftForm()) != SPELL_CAST_OK)
6925  return;
6926 
6927  if (form_change) // check aura active state from other form
6928  {
6929  AuraApplicationMapBounds range = GetAppliedAuras().equal_range(spellInfo->Id);
6930  for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr)
6931  if (!item || itr->second->GetBase()->GetCastItemGUID() == item->GetGUID())
6932  return;
6933  }
6934 
6935  LOG_DEBUG("entities.player", "WORLD: cast %s Equip spellId - %i", (item ? "item" : "itemset"), spellInfo->Id);
6936 
6937  CastSpell(this, spellInfo, true, item);
6938  }
6939  else
6940  {
6941  if (form_change) // check aura compatibility
6942  {
6943  // Cannot be used in this stance/form
6944  if (spellInfo->CheckShapeshift(GetShapeshiftForm()) == SPELL_CAST_OK)
6945  return; // and remove only not compatible at form change
6946  }
6947 
6948  if (item)
6949  RemoveAurasDueToItemSpell(spellInfo->Id, item->GetGUID()); // un-apply all spells, not only at-equipped
6950  else
6951  RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case)
6952 
6953  // Xinef: Remove Proc Spells and Summons
6954  for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
6955  {
6956  // Xinef: Remove procs
6957  if (spellInfo->Effects[i].TriggerSpell)
6958  RemoveAurasDueToSpell(spellInfo->Effects[i].TriggerSpell);
6959 
6960  // Xinef: remove minions summoned by item
6961  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SUMMON)
6962  RemoveAllMinionsByEntry(spellInfo->Effects[i].MiscValue);
6963  }
6964  }
6965 }
6966 
6967 void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
6968 {
6969  if (!target || !target->IsAlive() || target == this)
6970  return;
6971 
6972  // Xinef: do not use disarmed weapons, special exception - shaman ghost wolf form
6973  // Xinef: normal forms proc on hit enchants / built in item bonuses
6974  if (!CanUseAttackType(attType) || GetShapeshiftForm() == FORM_GHOSTWOLF)
6975  return;
6976 
6977  for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
6978  {
6979  // If usable, try to cast item spell
6980  if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
6981  if (!item->IsBroken())
6982  if (ItemTemplate const* proto = item->GetTemplate())
6983  {
6984  // Additional check for weapons
6985  if (proto->Class == ITEM_CLASS_WEAPON)
6986  {
6987  // offhand item cannot proc from main hand hit etc
6988  EquipmentSlots slot;
6989  switch (attType)
6990  {
6991  case BASE_ATTACK:
6992  slot = EQUIPMENT_SLOT_MAINHAND;
6993  break;
6994  case OFF_ATTACK:
6995  slot = EQUIPMENT_SLOT_OFFHAND;
6996  break;
6997  case RANGED_ATTACK:
6998  slot = EQUIPMENT_SLOT_RANGED;
6999  break;
7000  default:
7001  slot = EQUIPMENT_SLOT_END;
7002  break;
7003  }
7004  if (slot != i)
7005  continue;
7006  }
7007 
7008  CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
7009  }
7010  }
7011 }
7012 
7013 void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto)
7014 {
7015  if (!sScriptMgr->CanCastItemCombatSpell(this, target, attType, procVictim, procEx, item, proto))
7016  return;
7017 
7018  // Can do effect if any damage done to target
7019  if (procVictim & PROC_FLAG_TAKEN_DAMAGE)
7020  //if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
7021  {
7022  for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i)
7023  {
7024  _Spell const& spellData = proto->Spells[i];
7025 
7026  // no spell
7027  if (!spellData.SpellId)
7028  continue;
7029 
7030  // wrong triggering type
7032  continue;
7033 
7034  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellData.SpellId);
7035  if (!spellInfo)
7036  {
7037  LOG_ERROR("entities.player", "WORLD: unknown Item spellid %i", spellData.SpellId);
7038  continue;
7039  }
7040 
7041  // not allow proc extra attack spell at extra attack
7043  return;
7044 
7045  float chance = (float)spellInfo->ProcChance;
7046 
7047  if (spellData.SpellPPMRate)
7048  {
7049  uint32 WeaponSpeed = GetAttackTime(attType);
7050  chance = GetPPMProcChance(WeaponSpeed, spellData.SpellPPMRate, spellInfo);
7051  }
7052  else if (chance > 100.0f)
7053  {
7054  chance = GetWeaponProcChance();
7055  }
7056 
7057  if (roll_chance_f(chance) && sScriptMgr->OnCastItemCombatSpell(this, target, spellInfo, item))
7059  }
7060  }
7061 
7062  // item combat enchantments
7063  for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
7064  {
7065  uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
7066  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
7067  if (!pEnchant)
7068  continue;
7069 
7070  for (uint8 s = 0; s < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; ++s)
7071  {
7072  if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
7073  continue;
7074 
7075  SpellEnchantProcEntry const* entry = sSpellMgr->GetSpellEnchantProcEvent(enchant_id);
7076 
7077  if (entry && entry->procEx)
7078  {
7079  // Check hit/crit/dodge/parry requirement
7080  if ((entry->procEx & procEx) == 0)
7081  continue;
7082  }
7083  else
7084  {
7085  // Can do effect if any damage done to target
7086  if (!(procVictim & PROC_FLAG_TAKEN_DAMAGE))
7087  //if (!(damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE))
7088  continue;
7089  }
7090 
7091  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->spellid[s]);
7092  if (!spellInfo)
7093  {
7094  LOG_ERROR("entities.player", "Player::CastItemCombatSpell(%s, name: %s, enchant: %i): unknown spell %i is casted, ignoring...",
7095  GetGUID().ToString().c_str(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]);
7096  continue;
7097  }
7098 
7099  float chance = pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance();
7100 
7101  if (entry)
7102  {
7103  if (entry->PPMChance)
7104  chance = GetPPMProcChance(proto->Delay, entry->PPMChance, spellInfo);
7105  else if (entry->customChance)
7106  chance = (float)entry->customChance;
7107  }
7108 
7109  // Apply spell mods
7110  ApplySpellMod(pEnchant->spellid[s], SPELLMOD_CHANCE_OF_SUCCESS, chance);
7111 
7112  // Shiv has 100% chance to apply the poison
7113  if (FindCurrentSpellBySpellId(5938) && e_slot == TEMP_ENCHANTMENT_SLOT)
7114  chance = 100.0f;
7115 
7116  if (roll_chance_f(chance))
7117  {
7118  // Xinef: implement enchant charges
7119  if (uint32 charges = item->GetEnchantmentCharges(EnchantmentSlot(e_slot)))
7120  {
7121  if (!--charges)
7122  {
7123  ApplyEnchantment(item, EnchantmentSlot(e_slot), false);
7124  item->ClearEnchantment(EnchantmentSlot(e_slot));
7125  }
7126  else
7127  item->SetEnchantmentCharges(EnchantmentSlot(e_slot), charges);
7128  }
7129 
7130  if (spellInfo->IsPositive())
7132  else
7134  }
7135  }
7136  }
7137 }
7138 
7139 void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex)
7140 {
7141  if (!sScriptMgr->CanCastItemUseSpell(this, item, targets, cast_count, glyphIndex))
7142  return;
7143 
7144  ItemTemplate const* proto = item->GetTemplate();
7145  // special learning case
7146  if (proto->Spells[0].SpellId == 483 || proto->Spells[0].SpellId == 55884)
7147  {
7148  uint32 learn_spell_id = proto->Spells[0].SpellId;
7149  uint32 learning_spell_id = proto->Spells[1].SpellId;
7150 
7151  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(learn_spell_id);
7152  if (!spellInfo)
7153  {
7154  LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring ", proto->ItemId, learn_spell_id);
7155  SendEquipError(EQUIP_ERR_NONE, item, nullptr);
7156  return;
7157  }
7158 
7159  Spell* spell = new Spell(this, spellInfo, TRIGGERED_NONE);
7160  spell->m_CastItem = item;
7161  spell->m_cast_count = cast_count; //set count of casts
7162  spell->SetSpellValue(SPELLVALUE_BASE_POINT0, learning_spell_id);
7163  spell->prepare(&targets);
7164  return;
7165  }
7166 
7167  // use triggered flag only for items with many spell casts and for not first cast
7168  uint8 count = 0;
7169 
7170  std::list<Spell*> pushSpells;
7171  // item spells casted at use
7172  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
7173  {
7174  _Spell const& spellData = proto->Spells[i];
7175 
7176  // no spell
7177  if (!spellData.SpellId)
7178  continue;
7179 
7180  // wrong triggering type
7181  if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
7182  continue;
7183 
7184  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellData.SpellId);
7185  if (!spellInfo)
7186  {
7187  LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring", proto->ItemId, spellData.SpellId);
7188  continue;
7189  }
7190 
7191  if (HasSpellCooldown(spellInfo->Id))
7192  continue;
7193 
7194  Spell* spell = new Spell(this, spellInfo, (count > 0) ? TRIGGERED_FULL_MASK : TRIGGERED_NONE);
7195  spell->m_CastItem = item;
7196  spell->m_cast_count = cast_count; // set count of casts
7197  spell->m_glyphIndex = glyphIndex; // glyph index
7198  spell->InitExplicitTargets(targets);
7199 
7200  // Xinef: dont allow to cast such spells, it may happen that spell possess 2 spells, one for players and one for items / gameobjects
7201  // Xinef: if first one is cast on player, it may be deleted thus resulting in crash because second spell has saved pointer to the item
7202  // Xinef: there is one problem with scripts which wont be loaded at the moment of call
7203  SpellCastResult result = spell->CheckCast(true);
7204  if (result != SPELL_CAST_OK)
7205  {
7206  spell->SendCastResult(result);
7207  delete spell;
7208  continue;
7209  }
7210 
7211  pushSpells.push_back(spell);
7212  //spell->prepare(&targets);
7213 
7214  ++count;
7215  }
7216 
7217  // Item enchantments spells casted at use
7218  for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
7219  {
7220  uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
7221  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
7222  if (!pEnchant)
7223  continue;
7224  for (uint8 s = 0; s < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; ++s)
7225  {
7226  if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_USE_SPELL)
7227  continue;
7228 
7229  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->spellid[s]);
7230  if (!spellInfo)
7231  {
7232  LOG_ERROR("entities.player", "Player::CastItemUseSpell Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->spellid[s]);
7233  continue;
7234  }
7235 
7236  if (HasSpellCooldown(spellInfo->Id))
7237  continue;
7238 
7239  Spell* spell = new Spell(this, spellInfo, (count > 0) ? TRIGGERED_FULL_MASK : TRIGGERED_NONE);
7240  spell->m_CastItem = item;
7241  spell->m_cast_count = cast_count; // set count of casts
7242  spell->m_glyphIndex = glyphIndex; // glyph index
7243  spell->InitExplicitTargets(targets);
7244 
7245  // Xinef: dont allow to cast such spells, it may happen that spell possess 2 spells, one for players and one for items / gameobjects
7246  // Xinef: if first one is cast on player, it may be deleted thus resulting in crash because second spell has saved pointer to the item
7247  // Xinef: there is one problem with scripts which wont be loaded at the moment of call
7248  SpellCastResult result = spell->CheckCast(true);
7249  if (result != SPELL_CAST_OK)
7250  {
7251  spell->SendCastResult(result);
7252  delete spell;
7253  continue;
7254  }
7255 
7256  pushSpells.push_back(spell);
7257  //spell->prepare(&targets);
7258 
7259  ++count;
7260  }
7261  }
7262 
7263  // xinef: send all spells in one go, prevents crash because container is not set
7264  for (std::list<Spell*>::const_iterator itr = pushSpells.begin(); itr != pushSpells.end(); ++itr)
7265  (*itr)->prepare(&targets);
7266 }
7267 
7269 {
7270  LOG_DEBUG("entities.player.items", "_RemoveAllItemMods start.");
7271 
7272  for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
7273  {
7274  if (m_items[i])
7275  {
7276  ItemTemplate const* proto = m_items[i]->GetTemplate();
7277  if (!proto)
7278  continue;
7279 
7280  // item set bonuses not dependent from item broken state
7281  if (proto->ItemSet)
7282  RemoveItemsSetItem(this, proto);
7283 
7284  if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
7285  continue;
7286 
7287  ApplyItemEquipSpell(m_items[i], false);
7288  ApplyEnchantment(m_items[i], false);
7289  }
7290  }
7291 
7292  for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
7293  {
7294  if (m_items[i])
7295  {
7296  if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
7297  continue;
7298  ItemTemplate const* proto = m_items[i]->GetTemplate();
7299  if (!proto)
7300  continue;
7301 
7302  uint32 attacktype = Player::GetAttackBySlot(i);
7303  if (attacktype < MAX_ATTACK)
7304  _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false);
7305 
7306  _ApplyItemBonuses(proto, i, false);
7307 
7308  if (i == EQUIPMENT_SLOT_RANGED)
7310  }
7311  }
7312 
7313  LOG_DEBUG("entities.player.items", "_RemoveAllItemMods complete.");
7314 }
7315 
7317 {
7318  LOG_DEBUG("entities.player.items", "_ApplyAllItemMods start.");
7319 
7320  for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
7321  {
7322  if (m_items[i])
7323  {
7324  if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
7325  continue;
7326 
7327  ItemTemplate const* proto = m_items[i]->GetTemplate();
7328  if (!proto)
7329  continue;
7330 
7331  uint32 attacktype = Player::GetAttackBySlot(i);
7332  if (attacktype < MAX_ATTACK)
7334 
7335  _ApplyItemBonuses(proto, i, true);
7336 
7337  if (i == EQUIPMENT_SLOT_RANGED)
7339  }
7340  }
7341 
7342  for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
7343  {
7344  if (m_items[i])
7345  {
7346  ItemTemplate const* proto = m_items[i]->GetTemplate();
7347  if (!proto)
7348  continue;
7349 
7350  // item set bonuses not dependent from item broken state
7351  if (proto->ItemSet)
7352  AddItemsSetItem(this, m_items[i]);
7353 
7354  if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
7355  continue;
7356 
7357  ApplyItemEquipSpell(m_items[i], true);
7358  ApplyEnchantment(m_items[i], true);
7359  }
7360  }
7361 
7362  LOG_DEBUG("entities.player.items", "_ApplyAllItemMods complete.");
7363 }
7364 
7366 {
7367  for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
7368  {
7369  if (m_items[i])
7370  {
7371  if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i)))
7372  continue;
7373 
7374  ItemTemplate const* proto = m_items[i]->GetTemplate();
7375  if (!proto)
7376  continue;
7377 
7378  _ApplyItemMods(m_items[i], i, apply);
7379  }
7380  }
7381 }
7382 
7384 {
7385  // check ammo
7387  if (!ammo_id)
7388  return;
7389 
7390  float currentAmmoDPS;
7391 
7392  ItemTemplate const* ammo_proto = sObjectMgr->GetItemTemplate(ammo_id);
7393  if (!ammo_proto || ammo_proto->Class != ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto))
7394  currentAmmoDPS = 0.0f;
7395  else
7396  currentAmmoDPS = (ammo_proto->Damage[0].DamageMin + ammo_proto->Damage[0].DamageMax) / 2;
7397 
7398  sScriptMgr->OnApplyAmmoBonuses(this, ammo_proto, currentAmmoDPS);
7399 
7400  if (currentAmmoDPS == GetAmmoDPS())
7401  return;
7402 
7403  m_ammoDPS = currentAmmoDPS;
7404 
7405  if (CanModifyStats())
7407 }
7408 
7409 bool Player::CheckAmmoCompatibility(const ItemTemplate* ammo_proto) const
7410 {
7411  if (!ammo_proto)
7412  return false;
7413 
7414  // check ranged weapon
7416  if (!weapon || weapon->IsBroken())
7417  return false;
7418 
7419  ItemTemplate const* weapon_proto = weapon->GetTemplate();
7420  if (!weapon_proto || weapon_proto->Class != ITEM_CLASS_WEAPON)
7421  return false;
7422 
7423  // check ammo ws. weapon compatibility
7424  switch (weapon_proto->SubClass)
7425  {
7428  if (ammo_proto->SubClass != ITEM_SUBCLASS_ARROW)
7429  return false;
7430  break;
7432  if (ammo_proto->SubClass != ITEM_SUBCLASS_BULLET)
7433  return false;
7434  break;
7435  default:
7436  return false;
7437  }
7438 
7439  return true;
7440 }
7441 
7443 {
7444  uint32 count = 0;
7445 
7447  data << uint32(count); // placeholder
7448 
7449  for (GuidUnorderedSet::const_iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr)
7450  {
7451  uint32 questStatus = DIALOG_STATUS_NONE;
7452 
7453  if ((*itr).IsAnyTypeCreature())
7454  {
7455  // need also pet quests case support
7456  Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
7457  if (!questgiver || questgiver->IsHostileTo(this))
7458  continue;
7459  if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
7460  continue;
7461 
7462  questStatus = GetQuestDialogStatus(questgiver);
7463 
7464  data << questgiver->GetGUID();
7465  data << uint8(questStatus);
7466  ++count;
7467  }
7468  else if ((*itr).IsGameObject())
7469  {
7470  GameObject* questgiver = GetMap()->GetGameObject(*itr);
7471  if (!questgiver || questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
7472  continue;
7473 
7474  questStatus = GetQuestDialogStatus(questgiver);
7475 
7476  data << questgiver->GetGUID();
7477  data << uint8(questStatus);
7478  ++count;
7479  }
7480  }
7481 
7482  data.put<uint32>(0, count); // write real count
7483  GetSession()->SendPacket(&data);
7484 }
7485 
7486 /* If in a battleground a player dies, and an enemy removes the insignia, the player's bones is lootable
7487  Called by remove insignia spell effect */
7489 {
7490  // Xinef: If player is not in battleground and not in wintergrasp
7492  return;
7493 
7494  // If not released spirit, do it !
7495  if (m_deathTimer > 0)
7496  {
7497  m_deathTimer = 0;
7498  BuildPlayerRepop();
7499  RepopAtGraveyard();
7500  }
7501 
7503 
7504  // We have to convert player corpse to bones, not to be able to resurrect there
7505  // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
7506  Corpse* bones = GetMap()->ConvertCorpseToBones(GetGUID(), true);
7507  if (!bones)
7508  return;
7509 
7510  // Now we must make bones lootable, and send player loot
7512 
7513  // We store the level of our player in the gold field
7514  // We retrieve this information at Player::SendLoot()
7515  bones->loot.gold = getLevel();
7516  bones->lootRecipient = looterPlr;
7517  looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA);
7518 }
7519 
7521 {
7522  WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8 + 1));
7523  data << guid << uint8(1);
7524  SendDirectMessage(&data);
7525 }
7526 
7527 void Player::SendLoot(ObjectGuid guid, LootType loot_type)
7528 {
7529  if (ObjectGuid lguid = GetLootGUID())
7530  m_session->DoLootRelease(lguid);
7531 
7532  Loot* loot = 0;
7533  PermissionTypes permission = ALL_PERMISSION;
7534 
7535  LOG_DEBUG("loot", "Player::SendLoot");
7536  if (guid.IsGameObject())
7537  {
7538  LOG_DEBUG("loot", "guid.IsGameObject");
7539  GameObject* go = GetMap()->GetGameObject(guid);
7540 
7541  // not check distance for GO in case owned GO (fishing bobber case, for example)
7542  // And permit out of range GO with no owner in case fishing hole
7543  if (!go || (loot_type != LOOT_FISHINGHOLE && ((loot_type != LOOT_FISHING && loot_type != LOOT_FISHING_JUNK) || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this)) || (loot_type == LOOT_CORPSE && go->GetRespawnTime() && go->isSpawnedByDefault()))
7544  {
7546  SendLootRelease(guid);
7547  return;
7548  }
7549 
7550  loot = &go->loot;
7551 
7552  // Xinef: loot was generated and respawntime has passed since then, allow to recreate loot
7553  // Xinef: to avoid bugs, this rule covers spawned gameobjects only
7554  if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime() + go->GetRespawnDelay() < time(nullptr))
7555  go->SetLootState(GO_READY);
7556 
7557  if (go->getLootState() == GO_READY)
7558  {
7559  uint32 lootid = go->GetGOInfo()->GetLootId();
7560 
7561  //TODO: fix this big hack
7562  if ((go->GetEntry() == BG_AV_OBJECTID_MINE_N || go->GetEntry() == BG_AV_OBJECTID_MINE_S))
7563  if (Battleground* bg = GetBattleground())
7564  if (bg->GetBgTypeID(true) == BATTLEGROUND_AV)
7565  if (!bg->ToBattlegroundAV()->PlayerCanDoMineQuest(go->GetEntry(), GetTeamId()))
7566  {
7568  SendLootRelease(guid);
7569  return;
7570  }
7571 
7572  if (lootid)
7573  {
7574  loot->clear();
7575 
7576  Group* group = GetGroup();
7577  bool groupRules = (group && go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules);
7578 
7579  // check current RR player and get next if necessary
7580  if (groupRules)
7581  group->UpdateLooterGuid(go, true);
7582 
7583  loot->FillLoot(lootid, LootTemplates_Gameobject, this, !groupRules, false, go->GetLootMode(), go);
7584  go->SetLootGenerationTime();
7585 
7586  // get next RR player (for next loot)
7587  if (groupRules && !go->loot.empty())
7588  group->UpdateLooterGuid(go);
7589  }
7590  if (GameObjectTemplateAddon const* addon = go->GetTemplateAddon())
7591  loot->generateMoneyLoot(addon->mingold, addon->maxgold);
7592 
7593  if (loot_type == LOOT_FISHING)
7594  go->GetFishLoot(loot, this);
7595  else if (loot_type == LOOT_FISHING_JUNK)
7596  go->GetFishLootJunk(loot, this);
7597 
7598  if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules)
7599  {
7600  if (Group* group = GetGroup())
7601  {
7602  switch (group->GetLootMethod())
7603  {
7604  case GROUP_LOOT:
7605  // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
7606  group->GroupLoot(loot, go);
7607  break;
7608  case NEED_BEFORE_GREED:
7609  group->NeedBeforeGreed(loot, go);
7610  break;
7611  case MASTER_LOOT:
7612  group->MasterLoot(loot, go);
7613  break;
7614  default:
7615  break;
7616  }
7617  }
7618  }
7619 
7620  go->SetLootState(GO_ACTIVATED, this);
7621  }
7622 
7623  if (go->getLootState() == GO_ACTIVATED)
7624  {
7625  if (Group* group = GetGroup())
7626  {
7627  switch (group->GetLootMethod())
7628  {
7629  case MASTER_LOOT:
7630  permission = group->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION;
7631  break;
7632  case FREE_FOR_ALL:
7633  permission = ALL_PERMISSION;
7634  break;
7635  case ROUND_ROBIN:
7636  permission = ROUND_ROBIN_PERMISSION;
7637  break;
7638  default:
7639  permission = GROUP_PERMISSION;
7640  break;
7641  }
7642  }
7643  else
7644  permission = ALL_PERMISSION;
7645  }
7646  }
7647  else if (guid.IsItem())
7648  {
7649  Item* item = GetItemByGuid(guid);
7650 
7651  if (!item)
7652  {
7653  SendLootRelease(guid);
7654  return;
7655  }
7656 
7657  permission = OWNER_PERMISSION;
7658 
7659  loot = &item->loot;
7660 
7661  // Xinef: Store container id
7662  loot->containerGUID = item->GetGUID();
7663 
7664  if (!item->m_lootGenerated && !sLootItemStorage->LoadStoredLoot(item, this))
7665  {
7666  item->m_lootGenerated = true;
7667  loot->clear();
7668 
7669  switch (loot_type)
7670  {
7671  case LOOT_DISENCHANTING:
7672  loot->FillLoot(item->GetTemplate()->DisenchantID, LootTemplates_Disenchant, this, true);
7673  break;
7674  case LOOT_PROSPECTING:
7675  loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this, true);
7676  break;
7677  case LOOT_MILLING:
7678  loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this, true);
7679  break;
7680  default:
7682  loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0);
7683 
7684  // Xinef: Add to storage
7685  if (loot->gold > 0 || loot->unlootedCount > 0)
7686  sLootItemStorage->AddNewStoredLoot(loot, this);
7687 
7688  break;
7689  }
7690  }
7691  }
7692  else if (guid.IsCorpse()) // remove insignia
7693  {
7694  Corpse* bones = ObjectAccessor::GetCorpse(*this, guid);
7695 
7696  if (!bones || !(loot_type == LOOT_CORPSE || loot_type == LOOT_INSIGNIA) || bones->GetType() != CORPSE_BONES || !bones->HasFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE))
7697  {
7698  SendLootRelease(guid);
7699  return;
7700  }
7701 
7702  loot = &bones->loot;
7703 
7704  if (loot->loot_type == LOOT_NONE)
7705  {
7706  uint32 pLevel = bones->loot.gold;
7707  bones->loot.clear();
7708 
7709  // Xinef: For AV Achievement
7710  if (Battleground* bg = GetBattleground())
7711  {
7712  if (bg->GetBgTypeID(true) == BATTLEGROUND_AV)
7713  loot->FillLoot(1, LootTemplates_Creature, this, true);
7714  }
7715  // Xinef: For wintergrasp Quests
7716  else if (GetZoneId() == AREA_WINTERGRASP)
7717  loot->FillLoot(1, LootTemplates_Creature, this, true);
7718 
7719  // It may need a better formula
7720  // Now it works like this: lvl10: ~6copper, lvl70: ~9silver
7721  bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel) / 5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY));
7722  }
7723 
7724  if (bones->lootRecipient != this)
7725  permission = NONE_PERMISSION;
7726  else
7727  permission = OWNER_PERMISSION;
7728  }
7729  else
7730  {
7731  Creature* creature = GetMap()->GetCreature(guid);
7732 
7733  // must be in range and creature must be alive for pickpocket and must be dead for another loot
7734  if (!creature || creature->IsAlive() != (loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this, INTERACTION_DISTANCE))
7735  {
7736  SendLootRelease(guid);
7737  return;
7738  }
7739 
7740  if (loot_type == LOOT_PICKPOCKETING && IsFriendlyTo(creature))
7741  {
7742  SendLootRelease(guid);
7743  return;
7744  }
7745 
7746  loot = &creature->loot;
7747 
7748  if (loot_type == LOOT_PICKPOCKETING)
7749  {
7750  if (loot->loot_type != LOOT_PICKPOCKETING)
7751  {
7752  if (creature->CanGeneratePickPocketLoot())
7753  {
7754  creature->SetPickPocketLootTime();
7755  loot->clear();
7756 
7757  if (uint32 lootid = creature->GetCreatureTemplate()->pickpocketLootId)
7758  loot->FillLoot(lootid, LootTemplates_Pickpocketing, this, true);
7759 
7760  // Generate extra money for pick pocket loot
7761  const uint32 a = urand(0, creature->getLevel() / 2);
7762  const uint32 b = urand(0, getLevel() / 2);
7763  loot->gold = uint32(10 * (a + b) * sWorld->getRate(RATE_DROP_MONEY));
7764  permission = OWNER_PERMISSION;
7765  }
7766  else
7767  {
7768  permission = NONE_PERMISSION;
7770  return;
7771  }
7772  }
7773  }
7774  else
7775  {
7776  // Xinef: Exploit fix
7778  {
7780  return;
7781  }
7782 
7783  // the player whose group may loot the corpse
7784  Player* recipient = creature->GetLootRecipient();
7785  Group* recipientGroup = creature->GetLootRecipientGroup();
7786  if (!recipient && !recipientGroup)
7787  return;
7788 
7789  if (loot->loot_type == LOOT_NONE)
7790  {
7791  // for creature, loot is filled when creature is killed.
7792  if (recipientGroup)
7793  {
7794  switch (recipientGroup->GetLootMethod())
7795  {
7796  case GROUP_LOOT:
7797  // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
7798  recipientGroup->GroupLoot(loot, creature);
7799  break;
7800  case NEED_BEFORE_GREED:
7801  recipientGroup->NeedBeforeGreed(loot, creature);
7802  break;
7803  case MASTER_LOOT:
7804  recipientGroup->MasterLoot(loot, creature);
7805  break;
7806  default:
7807  break;
7808  }
7809  }
7810  }
7811 
7812  // if loot is already skinning loot then don't do anything else
7813  if (loot->loot_type == LOOT_SKINNING)
7814  {
7815  loot_type = LOOT_SKINNING;
7816  permission = creature->GetLootRecipientGUID() == GetGUID() ? OWNER_PERMISSION : NONE_PERMISSION;
7817  }
7818  else if (loot_type == LOOT_SKINNING)
7819  {
7820  loot->clear();
7821  loot->FillLoot(creature->GetCreatureTemplate()->SkinLootId, LootTemplates_Skinning, this, true);
7822  permission = OWNER_PERMISSION;
7823 
7824  //Inform instance if creature is skinned.
7825  if (InstanceScript* mapInstance = creature->GetInstanceScript())
7826  {
7827  mapInstance->CreatureLooted(creature, LOOT_SKINNING);
7828  }
7829 
7830  // Xinef: Set new loot recipient
7831  creature->SetLootRecipient(this, false);
7832  }
7833  // set group rights only for loot_type != LOOT_SKINNING
7834  else
7835  {
7836  if (recipientGroup)
7837  {
7838  if (GetGroup() == recipientGroup)
7839  {
7840  switch (recipientGroup->GetLootMethod())
7841  {
7842  case MASTER_LOOT:
7843  permission = recipientGroup->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION;
7844  break;
7845  case FREE_FOR_ALL:
7846  permission = ALL_PERMISSION;
7847  break;
7848  case ROUND_ROBIN:
7849  permission = ROUND_ROBIN_PERMISSION;
7850  break;
7851  default:
7852  permission = GROUP_PERMISSION;
7853  break;
7854  }
7855  }
7856  else
7857  permission = NONE_PERMISSION;
7858  }
7859  else if (recipient == this)
7860  permission = OWNER_PERMISSION;
7861  else
7862  permission = NONE_PERMISSION;
7863  }
7864  }
7865  }
7866 
7867  // LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client
7868  switch (loot_type)
7869  {
7870  case LOOT_INSIGNIA:
7871  loot_type = LOOT_SKINNING;
7872  break;
7873  case LOOT_FISHINGHOLE:
7874  loot_type = LOOT_FISHING;
7875  break;
7876  case LOOT_FISHING_JUNK:
7877  loot_type = LOOT_FISHING;
7878  break;
7879  default:
7880  break;
7881  }
7882 
7883  // need know merged fishing/corpse loot type for achievements
7884  loot->loot_type = loot_type;
7885 
7886  if (permission != NONE_PERMISSION)
7887  {
7888  SetLootGUID(guid);
7889 
7890  WorldPacket data(SMSG_LOOT_RESPONSE, (9 + 50)); // we guess size
7891  data << guid;
7892  data << uint8(loot_type);
7893  data << LootView(*loot, this, permission);
7894 
7895  SendDirectMessage(&data);
7896 
7897  // add 'this' player as one of the players that are looting 'loot'
7898  loot->AddLooter(GetGUID());
7899 
7900  if (loot_type == LOOT_CORPSE && !guid.IsItem())
7902  }
7903  else
7905 }
7906 
7908 {
7909  WorldPacket data(SMSG_LOOT_RESPONSE, 10);
7910  data << guid;
7911  data << uint8(LOOT_NONE);
7912  data << uint8(error);
7913  SendDirectMessage(&data);
7914 }
7915 
7917 {
7919  GetSession()->SendPacket(&data);
7920 }
7921 
7923 {
7924  WorldPacket data(SMSG_LOOT_REMOVED, 1);
7925  data << uint8(lootSlot);
7926  GetSession()->SendPacket(&data);
7927 }
7928 
7930 {
7931  // data depends on zoneid/mapid...
7932  Battleground* bg = GetBattleground();
7933  uint32 mapid = GetMapId();
7934  OutdoorPvP* pvp = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(zoneid);
7935  InstanceScript* instance = GetInstanceScript();
7936  Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(zoneid);
7937 
7938  LOG_DEBUG("network", "Sending SMSG_INIT_WORLD_STATES to Map: %u, Zone: %u", mapid, zoneid);
7939 
7940  WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (12 * 8)));
7941  data << uint32(mapid); // mapid
7942  data << uint32(zoneid); // zone id
7943  data << uint32(areaid); // area id, new 2.1.0
7944  size_t countPos = data.wpos();
7945  data << uint16(0); // count of uint64 blocks
7946  data << uint32(0x8d8) << uint32(0x0); // 1
7947  data << uint32(0x8d7) << uint32(0x0); // 2
7948  data << uint32(0x8d6) << uint32(0x0); // 3
7949  data << uint32(0x8d5) << uint32(0x0); // 4
7950  data << uint32(0x8d4) << uint32(0x0); // 5
7951  data << uint32(0x8d3) << uint32(0x0); // 6
7952  // 7 1 - Arena season in progress, 0 - end of season
7953  data << uint32(0xC77) << uint32(sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS));
7954  // 8 Arena season id
7955  data << uint32(0xF3D) << uint32(sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID));
7956 
7957  if (mapid == 530) // Outland
7958  {
7959  data << uint32(0x9bf) << uint32(0x0); // 7
7960  data << uint32(0x9bd) << uint32(0xF); // 8
7961  data << uint32(0x9bb) << uint32(0xF); // 9
7962  }
7963 
7965  {
7966  Player::bgZoneIdToFillWorldStates[zoneid](bg, data);
7967  }
7968  else
7969  {
7970  // insert <field> <value>
7971  switch (zoneid)
7972  {
7973  case 1: // Dun Morogh
7974  case 11: // Wetlands
7975  case 12: // Elwynn Forest
7976  case 38: // Loch Modan
7977  case 40: // Westfall
7978  case 51: // Searing Gorge
7979  case 1519: // Stormwind City
7980  case 1537: // Ironforge
7981  case 2257: // Deeprun Tram
7982  case 3703: // Shattrath City
7983  break;
7984  case 139: // Eastern Plaguelands
7985  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_EP)
7986  pvp->FillInitialWorldStates(data);
7987  else
7988  {
7989  data << uint32(0x97a) << uint32(0x0); // 10 2426
7990  data << uint32(0x917) << uint32(0x0); // 11 2327
7991  data << uint32(0x918) << uint32(0x0); // 12 2328
7992  data << uint32(0x97b) << uint32(0x32); // 13 2427
7993  data << uint32(0x97c) << uint32(0x32); // 14 2428
7994  data << uint32(0x933) << uint32(0x1); // 15 2355
7995  data << uint32(0x946) << uint32(0x0); // 16 2374
7996  data << uint32(0x947) << uint32(0x0); // 17 2375
7997  data << uint32(0x948) << uint32(0x0); // 18 2376
7998  data << uint32(0x949) << uint32(0x0); // 19 2377
7999  data << uint32(0x94a) << uint32(0x0); // 20 2378
8000  data << uint32(0x94b) << uint32(0x0); // 21 2379
8001  data << uint32(0x932) << uint32(0x0); // 22 2354
8002  data << uint32(0x934) << uint32(0x0); // 23 2356
8003  data << uint32(0x935) << uint32(0x0); // 24 2357
8004  data << uint32(0x936) << uint32(0x0); // 25 2358
8005  data << uint32(0x937) << uint32(0x0); // 26 2359
8006  data << uint32(0x938) << uint32(0x0); // 27 2360
8007  data << uint32(0x939) << uint32(0x1); // 28 2361
8008  data << uint32(0x930) << uint32(0x1); // 29 2352
8009  data << uint32(0x93a) << uint32(0x0); // 30 2362
8010  data << uint32(0x93b) << uint32(0x0); // 31 2363
8011  data << uint32(0x93c) << uint32(0x0); // 32 2364
8012  data << uint32(0x93d) << uint32(0x0); // 33 2365
8013  data << uint32(0x944) << uint32(0x0); // 34 2372
8014  data << uint32(0x945) << uint32(0x0); // 35 2373
8015  data << uint32(0x931) << uint32(0x1); // 36 2353
8016  data << uint32(0x93e) << uint32(0x0); // 37 2366
8017  data << uint32(0x931) << uint32(0x1); // 38 2367 ?? grey horde not in dbc! send for consistency's sake, and to match field count
8018  data << uint32(0x940) << uint32(0x0); // 39 2368
8019  data << uint32(0x941) << uint32(0x0); // 7 2369
8020  data << uint32(0x942) << uint32(0x0); // 8 2370
8021  data << uint32(0x943) << uint32(0x0); // 9 2371
8022  }
8023  break;
8024  case 1377: // Silithus
8025  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_SI)
8026  pvp->FillInitialWorldStates(data);
8027  else
8028  {
8029  // states are always shown
8030  data << uint32(2313) << uint32(0x0); // 7 ally silityst gathered
8031  data << uint32(2314) << uint32(0x0); // 8 horde silityst gathered
8032  data << uint32(2317) << uint32(0x0); // 9 max silithyst
8033  }
8034  // dunno about these... aq opening event maybe?
8035  data << uint32(2322) << uint32(0x0); // 10 sandworm N
8036  data << uint32(2323) << uint32(0x0); // 11 sandworm S
8037  data << uint32(2324) << uint32(0x0); // 12 sandworm SW
8038  data << uint32(2325) << uint32(0x0); // 13 sandworm E
8039  break;
8040  case 2597: // Alterac Valley
8041  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_AV)
8042  bg->FillInitialWorldStates(data);
8043  else
8044  {
8045  data << uint32(0x7ae) << uint32(0x1); // 7 snowfall n
8046  data << uint32(0x532) << uint32(0x1); // 8 frostwolfhut hc
8047  data << uint32(0x531) << uint32(0x0); // 9 frostwolfhut ac
8048  data << uint32(0x52e) << uint32(0x0); // 10 stormpike firstaid a_a
8049  data << uint32(0x571) << uint32(0x0); // 11 east frostwolf tower horde assaulted -unused
8050  data << uint32(0x570) << uint32(0x0); // 12 west frostwolf tower horde assaulted - unused
8051  data << uint32(0x567) << uint32(0x1); // 13 frostwolfe c
8052  data << uint32(0x566) << uint32(0x1); // 14 frostwolfw c
8053  data << uint32(0x550) << uint32(0x1); // 15 irondeep (N) ally
8054  data << uint32(0x544) << uint32(0x0); // 16 ice grave a_a
8055  data << uint32(0x536) << uint32(0x0); // 17 stormpike grave h_c
8056  data << uint32(0x535) << uint32(0x1); // 18 stormpike grave a_c
8057  data << uint32(0x518) << uint32(0x0); // 19 stoneheart grave a_a
8058  data << uint32(0x517) << uint32(0x0); // 20 stoneheart grave h_a
8059  data << uint32(0x574) << uint32(0x0); // 21 1396 unk
8060  data << uint32(0x573) << uint32(0x0); // 22 iceblood tower horde assaulted -unused
8061  data << uint32(0x572) << uint32(0x0); // 23 towerpoint horde assaulted - unused
8062  data << uint32(0x56f) << uint32(0x0); // 24 1391 unk
8063  data << uint32(0x56e) << uint32(0x0); // 25 iceblood a
8064  data << uint32(0x56d) << uint32(0x0); // 26 towerp a
8065  data << uint32(0x56c) << uint32(0x0); // 27 frostwolfe a
8066  data << uint32(0x56b) << uint32(0x0); // 28 froswolfw a
8067  data << uint32(0x56a) << uint32(0x1); // 29 1386 unk
8068  data << uint32(0x569) << uint32(0x1); // 30 iceblood c
8069  data << uint32(0x568) << uint32(0x1); // 31 towerp c
8070  data << uint32(0x565) << uint32(0x0); // 32 stoneh tower a
8071  data << uint32(0x564) << uint32(0x0); // 33 icewing tower a
8072  data << uint32(0x563) << uint32(0x0); // 34 dunn a
8073  data << uint32(0x562) << uint32(0x0); // 35 duns a
8074  data << uint32(0x561) << uint32(0x0); // 36 stoneheart bunker alliance assaulted - unused
8075  data << uint32(0x560) << uint32(0x0); // 37 icewing bunker alliance assaulted - unused
8076  data << uint32(0x55f) << uint32(0x0); // 38 dunbaldar south alliance assaulted - unused
8077  data << uint32(0x55e) << uint32(0x0); // 39 dunbaldar north alliance assaulted - unused
8078  data << uint32(0x55d) << uint32(0x0); // 40 stone tower d
8079  data << uint32(0x3c6) << uint32(0x0); // 41 966 unk
8080  data << uint32(0x3c4) << uint32(0x0); // 42 964 unk
8081  data << uint32(0x3c2) << uint32(0x0); // 43 962 unk
8082  data << uint32(0x516) << uint32(0x1); // 44 stoneheart grave a_c
8083  data << uint32(0x515) << uint32(0x0); // 45 stonheart grave h_c
8084  data << uint32(0x3b6) << uint32(0x0); // 46 950 unk
8085  data << uint32(0x55c) << uint32(0x0); // 47 icewing tower d
8086  data << uint32(0x55b) << uint32(0x0); // 48 dunn d
8087  data << uint32(0x55a) << uint32(0x0); // 49 duns d
8088  data << uint32(0x559) << uint32(0x0); // 50 1369 unk
8089  data << uint32(0x558) << uint32(0x0); // 51 iceblood d
8090  data << uint32(0x557) << uint32(0x0); // 52 towerp d
8091  data << uint32(0x556) << uint32(0x0); // 53 frostwolfe d
8092  data << uint32(0x555) << uint32(0x0); // 54 frostwolfw d
8093  data << uint32(0x554) << uint32(0x1); // 55 stoneh tower c
8094  data << uint32(0x553) << uint32(0x1); // 56 icewing tower c
8095  data << uint32(0x552) << uint32(0x1); // 57 dunn c
8096  data << uint32(0x551) << uint32(0x1); // 58 duns c
8097  data << uint32(0x54f) << uint32(0x0); // 59 irondeep (N) horde
8098  data << uint32(0x54e) << uint32(0x0); // 60 irondeep (N) ally
8099  data << uint32(0x54d) << uint32(0x1); // 61 mine (S) neutral
8100  data << uint32(0x54c) << uint32(0x0); // 62 mine (S) horde
8101  data << uint32(0x54b) << uint32(0x0); // 63 mine (S) ally
8102  data << uint32(0x545) << uint32(0x0); // 64 iceblood h_a
8103  data << uint32(0x543) << uint32(0x1); // 65 iceblod h_c
8104  data << uint32(0x542) << uint32(0x0); // 66 iceblood a_c
8105  data << uint32(0x540) << uint32(0x0); // 67 snowfall h_a
8106  data << uint32(0x53f) << uint32(0x0); // 68 snowfall a_a
8107  data << uint32(0x53e) << uint32(0x0); // 69 snowfall h_c
8108  data << uint32(0x53d) << uint32(0x0); // 70 snowfall a_c
8109  data << uint32(0x53c) << uint32(0x0); // 71 frostwolf g h_a
8110  data << uint32(0x53b) << uint32(0x0); // 72 frostwolf g a_a
8111  data << uint32(0x53a) << uint32(0x1); // 73 frostwolf g h_c
8112  data << uint32(0x539) << uint32(0x0); // 74 frostwolf g a_c
8113  data << uint32(0x538) << uint32(0x0); // 75 stormpike grave h_a
8114  data << uint32(0x537) << uint32(0x0); // 76 stormpike grave a_a
8115  data << uint32(0x534) << uint32(0x0); // 77 frostwolf hut h_a
8116  data << uint32(0x533) << uint32(0x0); // 78 frostwolf hut a_a
8117  data << uint32(0x530) << uint32(0x0); // 79 stormpike first aid h_a
8118  data << uint32(0x52f) << uint32(0x0); // 80 stormpike first aid h_c
8119  data << uint32(0x52d) << uint32(0x1); // 81 stormpike first aid a_c
8120  }
8121  break;
8122  case 3277: // Warsong Gulch
8123  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_WS)
8124  bg->FillInitialWorldStates(data);
8125  else
8126  {
8127  data << uint32(0x62d) << uint32(0x0); // 7 1581 alliance flag captures
8128  data << uint32(0x62e) << uint32(0x0); // 8 1582 horde flag captures
8129  data << uint32(0x609) << uint32(0x0); // 9 1545 unk, set to 1 on alliance flag pickup...
8130  data << uint32(0x60a) << uint32(0x0); // 10 1546 unk, set to 1 on horde flag pickup, after drop it's -1
8131  data << uint32(0x60b) << uint32(0x2); // 11 1547 unk
8132  data << uint32(0x641) << uint32(0x3); // 12 1601 unk (max flag captures?)
8133  data << uint32(0x922) << uint32(0x1); // 13 2338 horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing)
8134  data << uint32(0x923) << uint32(0x1); // 14 2339 alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing)
8135  }
8136  break;
8137  case 3358: // Arathi Basin
8138  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_AB)
8139  bg->FillInitialWorldStates(data);
8140  else
8141  {
8142  data << uint32(0x6e7) << uint32(0x0); // 7 1767 stables alliance
8143  data << uint32(0x6e8) << uint32(0x0); // 8 1768 stables horde
8144  data << uint32(0x6e9) << uint32(0x0); // 9 1769 unk, ST?
8145  data << uint32(0x6ea) << uint32(0x0); // 10 1770 stables (show/hide)
8146  data << uint32(0x6ec) << uint32(0x0); // 11 1772 farm (0 - horde controlled, 1 - alliance controlled)
8147  data << uint32(0x6ed) << uint32(0x0); // 12 1773 farm (show/hide)
8148  data << uint32(0x6ee) << uint32(0x0); // 13 1774 farm color
8149  data << uint32(0x6ef) << uint32(0x0); // 14 1775 gold mine color, may be FM?
8150  data << uint32(0x6f0) << uint32(0x0); // 15 1776 alliance resources
8151  data << uint32(0x6f1) << uint32(0x0); // 16 1777 horde resources
8152  data << uint32(0x6f2) << uint32(0x0); // 17 1778 horde bases
8153  data << uint32(0x6f3) << uint32(0x0); // 18 1779 alliance bases
8154  data << uint32(0x6f4) << uint32(0x640); // 19 1780 max resources (1600)
8155  data << uint32(0x6f6) << uint32(0x0); // 20 1782 blacksmith color
8156  data << uint32(0x6f7) << uint32(0x0); // 21 1783 blacksmith (show/hide)
8157  data << uint32(0x6f8) << uint32(0x0); // 22 1784 unk, bs?
8158  data << uint32(0x6f9) << uint32(0x0); // 23 1785 unk, bs?
8159  data << uint32(0x6fb) << uint32(0x0); // 24 1787 gold mine (0 - horde contr, 1 - alliance contr)
8160  data << uint32(0x6fc) << uint32(0x0); // 25 1788 gold mine (0 - conflict, 1 - horde)
8161  data << uint32(0x6fd) << uint32(0x0); // 26 1789 gold mine (1 - show/0 - hide)
8162  data << uint32(0x6fe) << uint32(0x0); // 27 1790 gold mine color
8163  data << uint32(0x700) << uint32(0x0); // 28 1792 gold mine color, wtf?, may be LM?
8164  data << uint32(0x701) << uint32(0x0); // 29 1793 lumber mill color (0 - conflict, 1 - horde contr)
8165  data << uint32(0x702) << uint32(0x0); // 30 1794 lumber mill (show/hide)
8166  data << uint32(0x703) << uint32(0x0); // 31 1795 lumber mill color color
8167  data << uint32(0x732) << uint32(0x1); // 32 1842 stables (1 - uncontrolled)
8168  data << uint32(0x733) << uint32(0x1); // 33 1843 gold mine (1 - uncontrolled)
8169  data << uint32(0x734) << uint32(0x1); // 34 1844 lumber mill (1 - uncontrolled)
8170  data << uint32(0x735) << uint32(0x1); // 35 1845 farm (1 - uncontrolled)
8171  data << uint32(0x736) << uint32(0x1); // 36 1846 blacksmith (1 - uncontrolled)
8172  data << uint32(0x745) << uint32(0x2); // 37 1861 unk
8173  data << uint32(0x7a3) << uint32(0x578); // 38 1955 warning limit (1400)
8174  }
8175  break;
8176  case 3820: // Eye of the Storm
8177  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_EY)
8178  bg->FillInitialWorldStates(data);
8179  else
8180  {
8181  data << uint32(0xac1) << uint32(0x0); // 7 2753 Horde Bases
8182  data << uint32(0xac0) << uint32(0x0); // 8 2752 Alliance Bases
8183  data << uint32(0xab6) << uint32(0x0); // 9 2742 Mage Tower - Horde conflict
8184  data << uint32(0xab5) << uint32(0x0); // 10 2741 Mage Tower - Alliance conflict
8185  data << uint32(0xab4) << uint32(0x0); // 11 2740 Fel Reaver - Horde conflict
8186  data << uint32(0xab3) << uint32(0x0); // 12 2739 Fel Reaver - Alliance conflict
8187  data << uint32(0xab2) << uint32(0x0); // 13 2738 Draenei - Alliance conflict
8188  data << uint32(0xab1) << uint32(0x0); // 14 2737 Draenei - Horde conflict
8189  data << uint32(0xab0) << uint32(0x0); // 15 2736 unk // 0 at start
8190  data << uint32(0xaaf) << uint32(0x0); // 16 2735 unk // 0 at start
8191  data << uint32(0xaad) << uint32(0x0); // 17 2733 Draenei - Horde control
8192  data << uint32(0xaac) << uint32(0x0); // 18 2732 Draenei - Alliance control
8193  data << uint32(0xaab) << uint32(0x1); // 19 2731 Draenei uncontrolled (1 - yes, 0 - no)
8194  data << uint32(0xaaa) << uint32(0x0); // 20 2730 Mage Tower - Alliance control
8195  data << uint32(0xaa9) << uint32(0x0); // 21 2729 Mage Tower - Horde control
8196  data << uint32(0xaa8) << uint32(0x1); // 22 2728 Mage Tower uncontrolled (1 - yes, 0 - no)
8197  data << uint32(0xaa7) << uint32(0x0); // 23 2727 Fel Reaver - Horde control
8198  data << uint32(0xaa6) << uint32(0x0); // 24 2726 Fel Reaver - Alliance control
8199  data << uint32(0xaa5) << uint32(0x1); // 25 2725 Fel Reaver uncontrolled (1 - yes, 0 - no)
8200  data << uint32(0xaa4) << uint32(0x0); // 26 2724 Boold Elf - Horde control
8201  data << uint32(0xaa3) << uint32(0x0); // 27 2723 Boold Elf - Alliance control
8202  data << uint32(0xaa2) << uint32(0x1); // 28 2722 Boold Elf uncontrolled (1 - yes, 0 - no)
8203  data << uint32(0xac5) << uint32(0x1); // 29 2757 Flag (1 - show, 0 - hide) - doesn't work exactly this way!
8204  data << uint32(0xad2) << uint32(0x1); // 30 2770 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag
8205  data << uint32(0xad1) << uint32(0x1); // 31 2769 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag
8206  data << uint32(0xabe) << uint32(0x0); // 32 2750 Horde resources
8207  data << uint32(0xabd) << uint32(0x0); // 33 2749 Alliance resources
8208  data << uint32(0xa05) << uint32(0x8e); // 34 2565 unk, constant?
8209  data << uint32(0xaa0) << uint32(0x0); // 35 2720 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0)
8210  data << uint32(0xa9f) << uint32(0x0); // 36 2719 Capturing progress-bar (0 - left, 100 - right)
8211  data << uint32(0xa9e) << uint32(0x0); // 37 2718 Capturing progress-bar (1 - show, 0 - hide)
8212  data << uint32(0xc0d) << uint32(0x17b); // 38 3085 unk
8213  // and some more ... unknown
8214  }
8215  break;
8216  // any of these needs change! the client remembers the prev setting!
8217  // ON EVERY ZONE LEAVE, RESET THE OLD ZONE'S WORLD STATE, BUT AT LEAST THE UI STUFF!
8218  case 3483: // Hellfire Peninsula
8219  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_HP)
8220  pvp->FillInitialWorldStates(data);
8221  else
8222  {
8223  data << uint32(0x9ba) << uint32(0x1); // 10 // add ally tower main gui icon // maybe should be sent only on login?
8224  data << uint32(0x9b9) << uint32(0x1); // 11 // add horde tower main gui icon // maybe should be sent only on login?
8225  data << uint32(0x9b5) << uint32(0x0); // 12 // show neutral broken hill icon // 2485
8226  data << uint32(0x9b4) << uint32(0x1); // 13 // show icon above broken hill // 2484
8227  data << uint32(0x9b3) << uint32(0x0); // 14 // show ally broken hill icon // 2483
8228  data << uint32(0x9b2) << uint32(0x0); // 15 // show neutral overlook icon // 2482
8229  data << uint32(0x9b1) << uint32(0x1); // 16 // show the overlook arrow // 2481
8230  data << uint32(0x9b0) << uint32(0x0); // 17 // show ally overlook icon // 2480
8231  data << uint32(0x9ae) << uint32(0x0); // 18 // horde pvp objectives captured // 2478
8232  data << uint32(0x9ac) << uint32(0x0); // 19 // ally pvp objectives captured // 2476
8233  data << uint32(2475) << uint32(100); //: ally / horde slider grey area // show only in direct vicinity!
8234  data << uint32(2474) << uint32(50); //: ally / horde slider percentage, 100 for ally, 0 for horde // show only in direct vicinity!
8235  data << uint32(2473) << uint32(0); //: ally / horde slider display // show only in direct vicinity!
8236  data << uint32(0x9a8) << uint32(0x0); // 20 // show the neutral stadium icon // 2472
8237  data << uint32(0x9a7) << uint32(0x0); // 21 // show the ally stadium icon // 2471
8238  data << uint32(0x9a6) << uint32(0x1); // 22 // show the horde stadium icon // 2470
8239  }
8240  break;
8241  case 3518: // Nagrand
8242  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_NA)
8243  pvp->FillInitialWorldStates(data);
8244  else
8245  {
8246  data << uint32(2503) << uint32(0x0); // 10
8247  data << uint32(2502) << uint32(0x0); // 11
8248  data << uint32(2493) << uint32(0x0); // 12
8249  data << uint32(2491) << uint32(0x0); // 13
8250 
8251  data << uint32(2495) << uint32(0x0); // 14
8252  data << uint32(2494) << uint32(0x0); // 15
8253  data << uint32(2497) << uint32(0x0); // 16
8254 
8255  data << uint32(2762) << uint32(0x0); // 17
8256  data << uint32(2662) << uint32(0x0); // 18
8257  data << uint32(2663) << uint32(0x0); // 19
8258  data << uint32(2664) << uint32(0x0); // 20
8259 
8260  data << uint32(2760) << uint32(0x0); // 21
8261  data << uint32(2670) << uint32(0x0); // 22
8262  data << uint32(2668) << uint32(0x0); // 23
8263  data << uint32(2669) << uint32(0x0); // 24
8264 
8265  data << uint32(2761) << uint32(0x0); // 25
8266  data << uint32(2667) << uint32(0x0); // 26
8267  data << uint32(2665) << uint32(0x0); // 27
8268  data << uint32(2666) << uint32(0x0); // 28
8269 
8270  data << uint32(2763) << uint32(0x0); // 29
8271  data << uint32(2659) << uint32(0x0); // 30
8272  data << uint32(2660) << uint32(0x0); // 31
8273  data << uint32(2661) << uint32(0x0); // 32
8274 
8275  data << uint32(2671) << uint32(0x0); // 33
8276  data << uint32(2676) << uint32(0x0); // 34
8277  data << uint32(2677) << uint32(0x0); // 35
8278  data << uint32(2672) << uint32(0x0); // 36
8279  data << uint32(2673) << uint32(0x0); // 37
8280  }
8281  break;
8282  case 3519: // Terokkar Forest
8283  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_TF)
8284  pvp->FillInitialWorldStates(data);
8285  else
8286  {
8287  data << uint32(0xa41) << uint32(0x0); // 10 // 2625 capture bar pos
8288  data << uint32(0xa40) << uint32(0x14); // 11 // 2624 capture bar neutral
8289  data << uint32(0xa3f) << uint32(0x0); // 12 // 2623 show capture bar
8290  data << uint32(0xa3e) << uint32(0x0); // 13 // 2622 horde towers controlled
8291  data << uint32(0xa3d) << uint32(0x5); // 14 // 2621 ally towers controlled
8292  data << uint32(0xa3c) << uint32(0x0); // 15 // 2620 show towers controlled
8293  data << uint32(0xa88) << uint32(0x0); // 16 // 2696 SE Neu
8294  data << uint32(0xa87) << uint32(0x0); // 17 // SE Horde
8295  data << uint32(0xa86) << uint32(0x0); // 18 // SE Ally
8296  data << uint32(0xa85) << uint32(0x0); // 19 //S Neu
8297  data << uint32(0xa84) << uint32(0x0); // 20 S Horde
8298  data << uint32(0xa83) << uint32(0x0); // 21 S Ally
8299  data << uint32(0xa82) << uint32(0x0); // 22 NE Neu
8300  data << uint32(0xa81) << uint32(0x0); // 23 NE Horde
8301  data << uint32(0xa80) << uint32(0x0); // 24 NE Ally
8302  data << uint32(0xa7e) << uint32(0x0); // 25 // 2686 N Neu
8303  data << uint32(0xa7d) << uint32(0x0); // 26 N Horde
8304  data << uint32(0xa7c) << uint32(0x0); // 27 N Ally
8305  data << uint32(0xa7b) << uint32(0x0); // 28 NW Ally
8306  data << uint32(0xa7a) << uint32(0x0); // 29 NW Horde
8307  data << uint32(0xa79) << uint32(0x0); // 30 NW Neutral
8308  data << uint32(0x9d0) << uint32(0x5); // 31 // 2512 locked time remaining seconds first digit
8309  data << uint32(0x9ce) << uint32(0x0); // 32 // 2510 locked time remaining seconds second digit
8310  data << uint32(0x9cd) << uint32(0x0); // 33 // 2509 locked time remaining minutes
8311  data << uint32(0x9cc) << uint32(0x0); // 34 // 2508 neutral locked time show
8312  data << uint32(0xad0) << uint32(0x0); // 35 // 2768 horde locked time show
8313  data << uint32(0xacf) << uint32(0x1); // 36 // 2767 ally locked time show
8314  }
8315  break;
8316  case 3521: // Zangarmarsh
8317  if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_ZM)
8318  pvp->FillInitialWorldStates(data);
8319  else
8320  {
8321  data << uint32(0x9e1) << uint32(0x0); // 10 //2529
8322  data << uint32(0x9e0) << uint32(0x0); // 11
8323  data << uint32(0x9df) << uint32(0x0); // 12
8324  data << uint32(0xa5d) << uint32(0x1); // 13 //2653
8325  data << uint32(0xa5c) << uint32(0x0); // 14 //2652 east beacon neutral
8326  data << uint32(0xa5b) << uint32(0x1); // 15 horde
8327  data << uint32(0xa5a) << uint32(0x0); // 16 ally
8328  data << uint32(0xa59) << uint32(0x1); // 17 // 2649 Twin spire graveyard horde 12???
8329  data << uint32(0xa58) << uint32(0x0); // 18 ally 14 ???
8330  data << uint32(0xa57) << uint32(0x0); // 19 neutral 7???
8331  data << uint32(0xa56) << uint32(0x0); // 20 // 2646 west beacon neutral
8332  data << uint32(0xa55) << uint32(0x1); // 21 horde
8333  data << uint32(0xa54) << uint32(0x0); // 22 ally
8334  data << uint32(0x9e7) << uint32(0x0); // 23 // 2535
8335  data << uint32(0x9e6) << uint32(0x0); // 24
8336  data << uint32(0x9e5) << uint32(0x0); // 25
8337  data << uint32(0xa00) << uint32(0x0); // 26 // 2560
8338  data << uint32(0x9ff) << uint32(0x1); // 27
8339  data << uint32(0x9fe) << uint32(0x0); // 28
8340  data << uint32(0x9fd) << uint32(0x0); // 29
8341  data << uint32(0x9fc) << uint32(0x1); // 30
8342  data << uint32(0x9fb) << uint32(0x0); // 31
8343  data << uint32(0xa62) << uint32(0x0); // 32 // 2658
8344  data << uint32(0xa61) << uint32(0x1); // 33
8345  data << uint32(0xa60) << uint32(0x1); // 34
8346  data << uint32(0xa5f) << uint32(0x0); // 35
8347  }
8348  break;
8349  case 3698: // Nagrand Arena
8350  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_NA)
8351  bg->FillInitialWorldStates(data);
8352  else
8353  {
8354  data << uint32(0xa0f) << uint32(0x0); // 7
8355  data << uint32(0xa10) << uint32(0x0); // 8
8356  data << uint32(0xa11) << uint32(0x0); // 9 show
8357  }
8358  break;
8359  case 3702: // Blade's Edge Arena
8360  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_BE)
8361  bg->FillInitialWorldStates(data);
8362  else
8363  {
8364  data << uint32(0x9f0) << uint32(0x0); // 7 gold
8365  data << uint32(0x9f1) << uint32(0x0); // 8 green
8366  data << uint32(0x9f3) << uint32(0x0); // 9 show
8367  }
8368  break;
8369  case 3968: // Ruins of Lordaeron
8370  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_RL)
8371  bg->FillInitialWorldStates(data);
8372  else
8373  {
8374  data << uint32(0xbb8) << uint32(0x0); // 7 gold
8375  data << uint32(0xbb9) << uint32(0x0); // 8 green
8376  data << uint32(0xbba) << uint32(0x0); // 9 show
8377  }
8378  break;
8379  case 4378: // Dalaran Sewers
8380  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_DS)
8381  bg->FillInitialWorldStates(data);
8382  else
8383  {
8384  data << uint32(3601) << uint32(0x0); // 7 gold
8385  data << uint32(3600) << uint32(0x0); // 8 green
8386  data << uint32(3610) << uint32(0x0); // 9 show
8387  }
8388  break;
8389  case 4384: // Strand of the Ancients
8390  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_SA)
8391  bg->FillInitialWorldStates(data);
8392  else
8393  {
8394  // 1-3 A defend, 4-6 H defend, 7-9 unk defend, 1 - ok, 2 - half destroyed, 3 - destroyed
8395  data << uint32(0xf09) << uint32(0x0); // 7 3849 Gate of Temple
8396  data << uint32(0xe36) << uint32(0x0); // 8 3638 Gate of Yellow Moon
8397  data << uint32(0xe27) << uint32(0x0); // 9 3623 Gate of Green Emerald
8398  data << uint32(0xe24) << uint32(0x0); // 10 3620 Gate of Blue Sapphire
8399  data << uint32(0xe21) << uint32(0x0); // 11 3617 Gate of Red Sun
8400  data << uint32(0xe1e) << uint32(0x0); // 12 3614 Gate of Purple Ametyst
8401 
8402  data << uint32(0xdf3) << uint32(0x0); // 13 3571 bonus timer (1 - on, 0 - off)
8403  data << uint32(0xded) << uint32(0x0); // 14 3565 Horde Attacker
8404  data << uint32(0xdec) << uint32(0x0); // 15 3564 Alliance Attacker
8405  // End Round (timer), better explain this by example, eg. ends in 19:59 -> A:BC
8406  data << uint32(0xde9) << uint32(0x0); // 16 3561 C
8407  data << uint32(0xde8) << uint32(0x0); // 17 3560 B
8408  data << uint32(0xde7) << uint32(0x0); // 18 3559 A
8409  data << uint32(0xe35) << uint32(0x0); // 19 3637 East g - Horde control
8410  data << uint32(0xe34) << uint32(0x0); // 20 3636 West g - Horde control
8411  data << uint32(0xe33) << uint32(0x0); // 21 3635 South g - Horde control
8412  data << uint32(0xe32) << uint32(0x0); // 22 3634 East g - Alliance control
8413  data << uint32(0xe31) << uint32(0x0); // 23 3633 West g - Alliance control
8414  data << uint32(0xe30) << uint32(0x0); // 24 3632 South g - Alliance control
8415  data << uint32(0xe2f) << uint32(0x0); // 25 3631 Chamber of Ancients - Horde control
8416  data << uint32(0xe2e) << uint32(0x0); // 26 3630 Chamber of Ancients - Alliance control
8417  data << uint32(0xe2d) << uint32(0x0); // 27 3629 Beach1 - Horde control
8418  data << uint32(0xe2c) << uint32(0x0); // 28 3628 Beach2 - Horde control
8419  data << uint32(0xe2b) << uint32(0x0); // 29 3627 Beach1 - Alliance control
8420  data << uint32(0xe2a) << uint32(0x0); // 30 3626 Beach2 - Alliance control
8421  // and many unks...
8422  }
8423  break;
8424  case 4406: // Ring of Valor
8425  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_RV)
8426  bg->FillInitialWorldStates(data);
8427  else
8428  {
8429  data << uint32(0xe10) << uint32(0x0); // 7 gold
8430  data << uint32(0xe11) << uint32(0x0); // 8 green
8431  data << uint32(0xe1a) << uint32(0x0); // 9 show
8432  }
8433  break;
8434  case 4710: // Isle of Conquest
8435  if (bg && bg->GetBgTypeID(true) == BATTLEGROUND_IC)
8436  bg->FillInitialWorldStates(data);
8437  else
8438  {
8439  data << uint32(4221) << uint32(1); // 7 BG_IC_ALLIANCE_RENFORT_SET
8440  data << uint32(4222) << uint32(1); // 8 BG_IC_HORDE_RENFORT_SET
8441  data << uint32(4226) << uint32(300); // 9 BG_IC_ALLIANCE_RENFORT
8442  data << uint32(4227) << uint32(300); // 10 BG_IC_HORDE_RENFORT
8443  data << uint32(4322) << uint32(1); // 11 BG_IC_GATE_FRONT_H_WS_OPEN
8444  data << uint32(4321) << uint32(1); // 12 BG_IC_GATE_WEST_H_WS_OPEN
8445  data << uint32(4320) << uint32(1); // 13 BG_IC_GATE_EAST_H_WS_OPEN
8446  data << uint32(4323) << uint32(1); // 14 BG_IC_GATE_FRONT_A_WS_OPEN
8447  data << uint32(4324) << uint32(1); // 15 BG_IC_GATE_WEST_A_WS_OPEN
8448  data << uint32(4325) << uint32(1); // 16 BG_IC_GATE_EAST_A_WS_OPEN
8449  data << uint32(4317) << uint32(1); // 17 unknown
8450 
8451  data << uint32(4301) << uint32(1); // 18 BG_IC_DOCKS_UNCONTROLLED
8452  data << uint32(4296) << uint32(1); // 19 BG_IC_HANGAR_UNCONTROLLED
8453  data << uint32(4306) << uint32(1); // 20 BG_IC_QUARRY_UNCONTROLLED
8454  data << uint32(4311) << uint32(1); // 21 BG_IC_REFINERY_UNCONTROLLED
8455  data << uint32(4294) << uint32(1); // 22 BG_IC_WORKSHOP_UNCONTROLLED
8456  data << uint32(4243) << uint32(1); // 23 unknown
8457  data << uint32(4345) << uint32(1); // 24 unknown
8458  }
8459  break;
8460  // The Ruby Sanctum
8461  case 4987:
8462  if (instance && mapid == 724)
8463  instance->FillInitialWorldStates(data);
8464  else
8465  {
8466  data << uint32(5049) << uint32(50); // 9 WORLDSTATE_CORPOREALITY_MATERIAL
8467  data << uint32(5050) << uint32(50); // 10 WORLDSTATE_CORPOREALITY_TWILIGHT
8468  data << uint32(5051) << uint32(0); // 11 WORLDSTATE_CORPOREALITY_TOGGLE
8469  }
8470  break;
8471  // Icecrown Citadel
8472  case 4812:
8473  if (instance && mapid == 631)
8474  instance->FillInitialWorldStates(data);
8475  else
8476  {
8477  data << uint32(4903) << uint32(0); // 9 WORLDSTATE_SHOW_TIMER (Blood Quickening weekly)
8478  data << uint32(4904) << uint32(30); // 10 WORLDSTATE_EXECUTION_TIME
8479  data << uint32(4940) << uint32(0); // 11 WORLDSTATE_SHOW_ATTEMPTS
8480  data << uint32(4941) << uint32(50); // 12 WORLDSTATE_ATTEMPTS_REMAINING
8481  data << uint32(4942) << uint32(50); // 13 WORLDSTATE_ATTEMPTS_MAX
8482  }
8483  break;
8484  // The Culling of Stratholme
8485  case 4100:
8486  if (instance && mapid == 595)
8487  instance->FillInitialWorldStates(data);
8488  else
8489  {
8490  data << uint32(3479) << uint32(0); // 9 WORLDSTATE_SHOW_CRATES
8491  data << uint32(3480) << uint32(0); // 10 WORLDSTATE_CRATES_REVEALED
8492  data << uint32(3504) << uint32(0); // 11 WORLDSTATE_WAVE_COUNT
8493  data << uint32(3931) << uint32(25); // 12 WORLDSTATE_TIME_GUARDIAN
8494  data << uint32(3932) << uint32(0); // 13 WORLDSTATE_TIME_GUARDIAN_SHOW
8495  }
8496  break;
8497  // The Oculus
8498  case 4228:
8499  if (instance && mapid == 578)
8500  instance->FillInitialWorldStates(data);
8501  else
8502  {
8503  data << uint32(3524) << uint32(0); // 9 WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW
8504  data << uint32(3486) << uint32(0); // 10 WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT
8505  }
8506  break;
8507  // Ulduar
8508  case 4273:
8509  if (instance && mapid == 603)
8510  instance->FillInitialWorldStates(data);
8511  else
8512  {
8513  data << uint32(4132) << uint32(0); // 9 WORLDSTATE_ALGALON_TIMER_ENABLED
8514  data << uint32(4131) << uint32(0); // 10 WORLDSTATE_ALGALON_DESPAWN_TIMER
8515  }
8516  break;
8517  // Halls of Refection
8518  case 4820:
8519  if (instance && mapid == 668)
8520  instance->FillInitialWorldStates(data);
8521  else
8522  {
8523  data << uint32(4884) << uint32(0); // 9 WORLD_STATE_HOR_WAVES_ENABLED
8524  data << uint32(4882) << uint32(0); // 10 WORLD_STATE_HOR_WAVE_COUNT
8525  }
8526  break;
8527  // Scarlet Enclave (DK starting zone)
8528  case 4298:
8529  // Get Mograine, GUID and ENTRY should NEVER change
8530  if (Creature* mograine = ObjectAccessor::GetCreature(*this, ObjectGuid::Create<HighGuid::Unit>(29173, 130956)))
8531  {
8532  if (CreatureAI* mograineAI = mograine->AI())
8533  {
8534  data << uint32(3590) << uint32(mograineAI->GetData(3590));
8535  data << uint32(3591) << uint32(mograineAI->GetData(3591));
8536  data << uint32(3592) << uint32(mograineAI->GetData(3592));
8537  data << uint32(3603) << uint32(mograineAI->GetData(3603));
8538  data << uint32(3604) << uint32(mograineAI->GetData(3604));
8539  data << uint32(3605) << uint32(mograineAI->GetData(3605));
8540  }
8541  }
8542  break;
8543  // Wintergrasp
8544  case 4197:
8545  if (bf && bf->GetTypeId() == BATTLEFIELD_WG)
8546  {
8547  bf->FillInitialWorldStates(data);
8548  break;
8549  }
8550  [[fallthrough]];
8551  default:
8552  data << uint32(0x914) << uint32(0x0); // 7
8553  data << uint32(0x913) << uint32(0x0); // 8
8554  data << uint32(0x912) << uint32(0x0); // 9
8555  data << uint32(0x915) << uint32(0x0); // 10
8556  break;
8557  }
8558  }
8559 
8560  uint16 length = (data.wpos() - countPos) / 8;
8561  data.put<uint16>(countPos, length);
8562 
8563  GetSession()->SendPacket(&data);
8566 }
8567 
8569 {
8570  for (uint32 i = 1; i < sBattlemasterListStore.GetNumRows(); ++i)
8571  {
8572  BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(i);
8573  if (bl && bl->HolidayWorldStateId)
8574  {
8577  else
8579  }
8580  }
8581 }
8582 
8584 {
8586  if (sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE))
8587  {
8588  if (BattlefieldWG* wg = (BattlefieldWG*)sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG))
8589  {
8592  SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, wg->IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward
8594 
8595  for (uint32 i = 0; i < 2; ++i)
8596  SendUpdateWorldState(ClockWorldState[i], uint32(time(nullptr) + (wg->GetTimer() / 1000)));
8597  }
8598  }
8599 }
8600 
8602 {
8603  uint32 rested_bonus = (uint32)GetRestBonus(); // xp for each rested bonus
8604 
8605  if (rested_bonus > xp) // max rested_bonus == xp or (r+x) = 200% xp
8606  rested_bonus = xp;
8607 
8608  SetRestBonus(GetRestBonus() - rested_bonus);
8609 
8610  LOG_DEBUG("entities.player", "Player gain %u xp (+ %u Rested Bonus). Rested points=%f", xp + rested_bonus, rested_bonus, GetRestBonus());
8611  return rested_bonus;
8612 }
8613 
8615 {
8617  data << guid;
8618  GetSession()->SendPacket(&data);
8619 }
8620 
8622 {
8623  WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8 + 4));
8624  data << guid;
8625  uint32 cost = sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST) ? 0 : resetTalentsCost();
8626  data << cost;
8627  GetSession()->SendPacket(&data);
8628 }
8629 
8631 {
8632  // This needs another gossip option + NPC text as a confirmation.
8633  // The confirmation gossip listid has the text: "Yes, please do."
8634  Pet* pet = GetPet();
8635 
8636  if (!pet || pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0)
8637  return;
8638 
8639  CharmInfo* charmInfo = pet->GetCharmInfo();
8640  if (!charmInfo)
8641  {
8642  LOG_ERROR("entities.player", "Object (%s) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().ToString().c_str());
8643  return;
8644  }
8645  pet->resetTalents();
8646  SendTalentsInfoData(true);
8647 }
8648 
8650 {
8651  if (ObjectGuid pet_guid = GetPetGUID())
8652  {
8653  if (!pet_guid.IsPet())
8654  return nullptr;
8655 
8656  Pet* pet = ObjectAccessor::GetPet(*this, pet_guid);
8657 
8658  if (!pet)
8659  return nullptr;
8660 
8661  if (IsInWorld() && pet)
8662  return pet;
8663 
8664  //there may be a guardian in slot
8665  //LOG_ERROR("entities.player", "Player::GetPet: Pet %s not exist.", pet_guid.ToString().c_str());
8666  //const_cast<Player*>(this)->SetPetGUID(0);
8667  }
8668 
8669  return nullptr;
8670 }
8671 
8672 void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
8673 {
8674  if (!pet)
8675  pet = GetPet();
8676 
8677  if (pet)
8678  {
8679  // xinef: dont save dead pet as current, save him not in slot
8680  if (!pet->IsAlive() && mode == PET_SAVE_AS_CURRENT && pet->getPetType() == HUNTER_PET)
8681  {
8682  mode = PET_SAVE_NOT_IN_SLOT;
8684  }
8685 
8686  LOG_DEBUG("entities.pet", "RemovePet %u, %u, %u", pet->GetEntry(), mode, returnreagent);
8687  if (pet->m_removed)
8688  return;
8689  }
8690 
8691  if (returnreagent && (pet || m_temporaryUnsummonedPetNumber) && !InBattleground())
8692  {
8693  //returning of reagents only for players, so best done here
8694  uint32 spellId = pet ? pet->GetUInt32Value(UNIT_CREATED_BY_SPELL) : m_oldpetspell;
8695  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
8696 
8697  if (spellInfo)
8698  {
8699  for (uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i)
8700  {
8701  if (spellInfo->Reagent[i] > 0)
8702  {
8703  ItemPosCountVec dest; //for succubus, voidwalker, felhunter and felguard credit soulshard when despawn reason other than death (out of range, logout)
8704  InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellInfo->Reagent[i], spellInfo->ReagentCount[i]);
8705  if (msg == EQUIP_ERR_OK)
8706  {
8707  Item* item = StoreNewItem(dest, spellInfo->Reagent[i], true);
8708  if (IsInWorld())
8709  SendNewItem(item, spellInfo->ReagentCount[i], true, false);
8710  }
8711  }
8712  }
8713  }
8715  }
8716 
8717  if (!pet || pet->GetOwnerGUID() != GetGUID())
8718  return;
8719 
8720  pet->CombatStop();
8721 
8722  // only if current pet in slot
8723  pet->SavePetToDB(mode, true);
8724 
8725  SetMinion(pet, false);
8726 
8727  pet->AddObjectToRemoveList();
8728  pet->m_removed = true;
8729 
8730  if (pet->isControlled())
8731  {
8732  WorldPacket data(SMSG_PET_SPELLS, 8);
8733  data << uint64(0);
8734  GetSession()->SendPacket(&data);
8735 
8736  if (GetGroup())
8738  }
8739 
8741  {
8744  }
8745 }
8746 
8748 {
8749  Unit* charm = GetCharm();
8750  if (!charm)
8751  return;
8752 
8753  if (charm->GetTypeId() == TYPEID_UNIT)
8754  {
8756  ((Puppet*)charm)->UnSummon();
8757  else if (charm->IsVehicle())
8758  ExitVehicle();
8759  }
8760  if (GetCharmGUID())
8761  charm->RemoveCharmAuras();
8762 
8763  if (GetCharmGUID())
8764  {
8765  LOG_FATAL("entities.player", "Player %s (%s is not able to uncharm unit (%s)", GetName().c_str(), GetGUID().ToString().c_str(), GetCharmGUID().ToString().c_str());
8766  if (charm->GetCharmerGUID())
8767  {
8768  LOG_FATAL("entities.player", "Charmed unit has charmer %s", charm->GetCharmerGUID().ToString().c_str());
8769  ABORT();
8770  }
8771  else
8772  SetCharm(charm, false);
8773  }
8774 }
8775 
8776 void Player::Say(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
8777 {
8778  std::string _text(text);
8779  sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
8780 #ifdef ELUNA
8781  if (!sEluna->OnChat(this, CHAT_MSG_SAY, language, _text))
8782  return;
8783 #endif
8784 
8785  WorldPacket data;
8786  ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, language, this, this, _text);
8787  SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
8788 }
8789 
8790 void Player::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
8791 {
8792  Talk(textId, CHAT_MSG_SAY, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), target);
8793 }
8794 
8795 void Player::Yell(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
8796 {
8797  std::string _text(text);
8798  sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
8799 #ifdef ELUNA
8800  if (!sEluna->OnChat(this, CHAT_MSG_YELL, language, _text))
8801  return;
8802 #endif
8803 
8804  WorldPacket data;
8805  ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, language, this, this, _text);
8806  SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
8807 }
8808 
8809 void Player::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
8810 {
8811  Talk(textId, CHAT_MSG_YELL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), target);
8812 }
8813 
8814 void Player::TextEmote(std::string_view text, WorldObject const* /*= nullptr*/, bool /*= false*/)
8815 {
8816  std::string _text(text);
8817  sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
8818 #ifdef ELUNA
8819  if (!sEluna->OnChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
8820  return;
8821 #endif
8822 
8823  WorldPacket data;
8824  ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
8826 }
8827 
8828 void Player::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool /*isBossEmote = false*/)
8829 {
8830  Talk(textId, CHAT_MSG_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target);
8831 }
8832 
8833 void Player::Whisper(std::string_view text, Language language, Player* target, bool /*= false*/)
8834 {
8835  ASSERT(target);
8836 
8837  bool isAddonMessage = language == LANG_ADDON;
8838 
8839  if (!isAddonMessage) // if not addon data
8840  language = LANG_UNIVERSAL; // whispers should always be readable
8841 
8842  std::string _text(text);
8843  sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
8844 #ifdef ELUNA
8845  if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, target))
8846  {
8847  return;
8848  }
8849 #endif
8850 
8851  WorldPacket data;
8852  ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, language, this, this, _text);
8853  target->GetSession()->SendPacket(&data);
8854 
8855  // rest stuff shouldn't happen in case of addon message
8856  if (isAddonMessage)
8857  return;
8858 
8859  ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER_INFORM, Language(language), target, target, _text);
8860  GetSession()->SendPacket(&data);
8861 
8862  if (!isAcceptWhispers() && !IsGameMaster() && !target->IsGameMaster())
8863  {
8864  SetAcceptWhispers(true);
8866  }
8867 
8868  // announce afk or dnd message
8869  if (target->isAFK())
8870  {
8871  ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, target->GetName().c_str(), target->autoReplyMsg.c_str());
8872  }
8873  else if (target->isDND())
8874  {
8875  ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, target->GetName().c_str(), target->autoReplyMsg.c_str());
8876  }
8877 }
8878 
8879 void Player::Whisper(uint32 textId, Player* target, bool /*isBossWhisper = false*/)
8880 {
8881  if (!target)
8882  {
8883  return;
8884  }
8885 
8886  BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId);
8887  if (!bct)
8888  {
8889  LOG_ERROR("entities.unit", "Player::Whisper: `broadcast_text` was not %u found", textId);
8890  return;
8891  }
8892 
8893  LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex();
8894  WorldPacket data;
8895  ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
8896  target->SendDirectMessage(&data);
8897 }
8898 
8900 {
8901  Pet* pet = GetPet();
8902 
8903  if (!pet)
8904  return;
8905 
8906  LOG_DEBUG("entities.pet", "Pet Spells Groups");
8907 
8908  CharmInfo* charmInfo = pet->GetCharmInfo();
8909 
8910  WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1);
8911  data << pet->GetGUID();
8912  data << uint16(pet->GetCreatureTemplate()->family); // creature family (required for pet talents)
8913  data << uint32(pet->GetDuration());
8914  data << uint8(pet->GetReactState());
8915  data << uint8(charmInfo->GetCommandState());
8916  data << uint16(0); // Flags, mostly unknown
8917 
8918  // action bar loop
8919  charmInfo->BuildActionBar(&data);
8920 
8921  size_t spellsCountPos = data.wpos();
8922 
8923  // spells count
8924  uint8 addlist = 0;
8925  data << uint8(addlist); // placeholder
8926 
8927  if (pet->IsPermanentPetFor(this))
8928  {
8929  // spells loop
8930  for (PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
8931  {
8932  if (itr->second.state == PETSPELL_REMOVED)
8933  continue;
8934 
8935  data << uint32(MAKE_UNIT_ACTION_BUTTON(itr->first, itr->second.active));
8936  ++addlist;
8937  }
8938  }
8939 
8940  data.put<uint8>(spellsCountPos, addlist);
8941 
8942  uint8 cooldownsCount = pet->m_CreatureSpellCooldowns.size();
8943  data << uint8(cooldownsCount);
8944 
8945  uint32 curTime = World::GetGameTimeMS();
8947 
8948  for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
8949  {
8950  uint16 category = itr->second.category;
8951  uint32 cooldown = (itr->second.end > curTime) ? itr->second.end - curTime : 0;
8952 
8953  data << uint32(itr->first); // spellid
8954  data << uint16(itr->second.category); // spell category
8955 
8956  // send infinity cooldown in special format
8957  if (itr->second.end >= infTime)
8958  {
8959  data << uint32(1); // cooldown
8960  data << uint32(0x80000000); // category cooldown
8961  continue;
8962  }
8963 
8964  data << uint32(category ? 0 : cooldown); // cooldown
8965  data << uint32(category ? cooldown : 0); // category cooldown
8966  }
8967 
8968  GetSession()->SendPacket(&data);
8969 }
8970 
8972 {
8973  Unit* charm = GetCharm();
8974  if (!charm)
8975  return;
8976 
8977  CharmInfo* charmInfo = charm->GetCharmInfo();
8978 
8979  if (!charmInfo)
8980  {
8981  LOG_ERROR("entities.player", "Player::PossessSpellInitialize(): charm (%s) has no charminfo!", charm->GetGUID().ToString().c_str());
8982  return;
8983  }
8984 
8985  WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1);
8986  data << charm->GetGUID();
8987  data << uint16(0);
8988  data << uint32(0);
8989  data << uint32(0);
8990 
8991  charmInfo->BuildActionBar(&data);
8992 
8993  data << uint8(0); // spells count
8994  data << uint8(0); // cooldowns count
8995 
8996  GetSession()->SendPacket(&data);
8997 }
8998 
9000 {
9001  Creature* vehicle = GetVehicleCreatureBase();
9002  if (!vehicle)
9003  return;
9004 
9005  uint8 cooldownCount = vehicle->m_CreatureSpellCooldowns.size();
9006 
9007  WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * 10 + 1 + 1 + cooldownCount * (4 + 2 + 4 + 4));
9008  data << vehicle->GetGUID(); // Guid
9009  data << uint16(0); // Pet Family (0 for all vehicles)
9010  data << uint32(vehicle->IsSummon() ? vehicle->ToTempSummon()->GetTimer() : 0); // Duration
9011  // The following three segments are read by the client as one uint32
9012  data << uint8(vehicle->GetReactState()); // React State
9013  data << uint8(0); // Command State
9014  data << uint16(0x800); // DisableActions (set for all vehicles)
9015 
9016  for (uint32 i = 0; i < MAX_CREATURE_SPELLS; ++i)
9017  {
9018  uint32 spellId = vehicle->m_spells[i];
9019  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
9020  if (!spellInfo)
9021  {
9022  data << uint16(0) << uint8(0) << uint8(i + 8);
9023  continue;
9024  }
9025 
9026  ConditionList conditions = sConditionMgr->GetConditionsForVehicleSpell(vehicle->GetEntry(), spellId);
9027  if (!sConditionMgr->IsObjectMeetToConditions(this, vehicle, conditions))
9028  {
9029  LOG_DEBUG("condition", "VehicleSpellInitialize: conditions not met for Vehicle entry %u spell %u", vehicle->ToCreature()->GetEntry(), spellId);
9030  data << uint16(0) << uint8(0) << uint8(i + 8);
9031  continue;
9032  }
9033 
9034  if (spellInfo->IsPassive())
9035  vehicle->CastSpell(vehicle, spellId, true);
9036 
9037  data << uint32(MAKE_UNIT_ACTION_BUTTON(spellId, i + 8));
9038  }
9039 
9041  data << uint32(0);
9042 
9043  data << uint8(0); // Auras?
9044 
9045  // Cooldowns
9046  data << uint8(cooldownCount);
9047 
9048  uint32 curTime = World::GetGameTimeMS();
9050 
9051  for (CreatureSpellCooldowns::const_iterator itr = vehicle->m_CreatureSpellCooldowns.begin(); itr != vehicle->m_CreatureSpellCooldowns.end(); ++itr)
9052  {
9053  uint16 category = itr->second.category;
9054  uint32 cooldown = (itr->second.end > curTime) ? itr->second.end - curTime : 0;
9055 
9056  data << uint32(itr->first); // spellid
9057  data << uint16(itr->second.category); // spell category
9058 
9059  // send infinity cooldown in special format
9060  if (itr->second.end >= infTime)
9061  {
9062  data << uint32(1); // cooldown
9063  data << uint32(0x80000000); // category cooldown
9064  continue;
9065  }
9066 
9067  data << uint32(category ? 0 : cooldown); // cooldown
9068  data << uint32(category ? cooldown : 0); // category cooldown
9069  }
9070 
9071  GetSession()->SendPacket(&data);
9072 }
9073 
9075 {
9076  Unit* charm = GetFirstControlled();
9077  if (!charm)
9078  return;
9079 
9080  CharmInfo* charmInfo = charm->GetCharmInfo();
9081  if (!charmInfo)
9082  {
9083  LOG_ERROR("entities.player", "Player::CharmSpellInitialize(): the player's charm (%s) has no charminfo!", charm->GetGUID().ToString().c_str());
9084  return;
9085  }
9086 
9087  uint8 addlist = 0;
9088  if (charm->GetTypeId() != TYPEID_PLAYER)
9089  {
9090  //CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate();
9091  //if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)
9092  {
9093  for (uint32 i = 0; i < MAX_SPELL_CHARM; ++i)
9094  if (charmInfo->GetCharmSpell(i)->GetAction())
9095  ++addlist;
9096  }
9097  }
9098 
9099  WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 4 * addlist + 1);
9100  data << charm->GetGUID();
9101  data << uint16(0);
9102  data << uint32(0);
9103 
9104  if (charm->GetTypeId() != TYPEID_PLAYER)
9105  data << uint8(charm->ToCreature()->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
9106  else
9107  data << uint32(0);
9108 
9109  charmInfo->BuildActionBar(&data);
9110 
9111  data << uint8(addlist);
9112 
9113  if (addlist)
9114  {
9115  for (uint32 i = 0; i < MAX_SPELL_CHARM; ++i)
9116  {
9117  CharmSpellInfo* cspell = charmInfo->GetCharmSpell(i);
9118  if (cspell->GetAction())
9119  data << uint32(cspell->packedData);
9120  }
9121  }
9122 
9123  data << uint8(0); // cooldowns count
9124 
9125  GetSession()->SendPacket(&data);
9126 }
9127 
9129 {
9130  WorldPacket data(SMSG_PET_SPELLS, 8);
9131  data << uint64(0);
9132  GetSession()->SendPacket(&data);
9133 }
9134 
9136 {
9137  if (!mod || !spell)
9138  return false;
9139 
9140  return spell->m_appliedMods.find(mod->ownerAura) != spell->m_appliedMods.end();
9141 }
9142 
9143 bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell)
9144 {
9145  if (!mod || !spellInfo)
9146  return false;
9147 
9148  // Mod out of charges
9149  if (spell && mod->charges == -1 && spell->m_appliedMods.find(mod->ownerAura) == spell->m_appliedMods.end())
9150  return false;
9151 
9152  // +duration to infinite duration spells making them limited
9153  if (mod->op == SPELLMOD_DURATION && spellInfo->GetDuration() == -1)
9154  return false;
9155 
9156  return spellInfo->IsAffectedBySpellMod(mod);
9157 }
9158 
9159 // Binary predicate for sorting SpellModifiers
9161 {
9162 public:
9164  bool operator() (const SpellModifier* a, const SpellModifier* b) const
9165  {
9166  if (a->type != b->type)
9167  return a->type == SPELLMOD_FLAT;
9168  return a->value < b->value;
9169  }
9170 };
9172 {
9173 public:
9175  bool operator() (const SpellModifier* a, const SpellModifier* b) const
9176  {
9177  if (a->type != b->type)
9178  return a->type == SPELLMOD_FLAT;
9179  if (a->spellId == 44401)
9180  return true;
9181  if (b->spellId == 44401)
9182  return false;
9183  return a->value < b->value;
9184  }
9185 };
9186 
9188 {
9189  LOG_DEBUG("spells.aura", "Player::AddSpellMod %d", mod->spellId);
9191 
9192  int i = 0;
9193  flag96 _mask = 0;
9194  for (int eff = 0; eff < 96; ++eff)
9195  {
9196  if (eff != 0 && eff % 32 == 0)
9197  _mask[i++] = 0;
9198 
9199  _mask[i] = uint32(1) << (eff - (32 * i));
9200  if (mod->mask & _mask)
9201  {
9202  int32 val = 0;
9203  for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr)
9204  {
9205  if ((*itr)->type == mod->type && (*itr)->mask & _mask)
9206  val += (*itr)->value;
9207  }
9208  val += apply ? mod->value : -(mod->value);
9209  WorldPacket data(Opcode, (1 + 1 + 4));
9210  data << uint8(eff);
9211  data << uint8(mod->op);
9212  data << int32(val);
9213  SendDirectMessage(&data);
9214  }
9215  }
9216 
9217  if (apply)
9218  {
9219  m_spellMods[mod->op].push_back(mod);
9220  if (getClass() == CLASS_MAGE)
9221  m_spellMods[mod->op].sort(MageSpellModPred());
9222  else
9223  m_spellMods[mod->op].sort(SpellModPred());
9224  }
9225  else
9226  {
9227  m_spellMods[mod->op].remove(mod);
9228  // mods bound to aura will be removed in AuraEffect::~AuraEffect
9229  if (!mod->ownerAura)
9230  delete mod;
9231  }
9232 }
9233 
9234 // Restore spellmods in case of failed cast
9235 void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId, Aura* aura)
9236 {
9237  if (!spell || spell->m_appliedMods.empty())
9238  return;
9239 
9240  std::list<Aura*> aurasQueue;
9241 
9242  for (uint8 i = 0; i < MAX_SPELLMOD; ++i)
9243  {
9244  for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
9245  {
9246  SpellModifier* mod = *itr;
9247 
9248  // Spellmods without aura set cannot be charged
9249  if (!mod->ownerAura || !mod->ownerAura->IsUsingCharges())
9250  continue;
9251 
9252  // Restore only specific owner aura mods
9253  if (ownerAuraId && (ownerAuraId != mod->ownerAura->GetSpellInfo()->Id))
9254  continue;
9255 
9256  if (aura && mod->ownerAura != aura)
9257  continue;
9258 
9259  // Check if mod affected this spell
9260  // First, check if the mod aura applied at least one spellmod to this spell
9261  Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
9262  if (iterMod == spell->m_appliedMods.end())
9263  continue;
9264  // Second, check if the current mod is one of those applied by the mod aura
9265  if (!(mod->mask & spell->m_spellInfo->SpellFamilyFlags))
9266  continue;
9267 
9268  // remove from list - This will be done after all mods have been gone through
9269  // to ensure we iterate over all mods of an aura before removing said aura
9270  // from applied mods (Else, an aura with two mods on the current spell would
9271  // only see the first of its modifier restored)
9272  aurasQueue.push_back(mod->ownerAura);
9273 
9274  // add mod charges back to mod
9275  if (mod->charges == -1)
9276  mod->charges = 1;
9277  else
9278  mod->charges++;
9279 
9280  // Do not set more spellmods than available
9281  if (mod->ownerAura->GetCharges() < mod->charges)
9282  mod->charges = mod->ownerAura->GetCharges();
9283 
9284  // Skip this check for now - aura charges may change due to various reason
9286  //ASSERT (mod->ownerAura->GetCharges() <= mod->charges);
9287  }
9288  }
9289 
9290  for (std::list<Aura*>::iterator itr = aurasQueue.begin(); itr != aurasQueue.end(); ++itr)
9291  {
9292  Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(*itr);
9293  if (iterMod != spell->m_appliedMods.end())
9294  spell->m_appliedMods.erase(iterMod);
9295  }
9296 
9297  // Xinef: clear the list just do be sure
9298  if (!ownerAuraId && !aura)
9299  spell->m_appliedMods.clear();
9300 }
9301 
9302 void Player::RestoreAllSpellMods(uint32 ownerAuraId, Aura* aura)
9303 {
9304  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
9305  if (m_currentSpells[i])
9306  RestoreSpellMods(m_currentSpells[i], ownerAuraId, aura);
9307 }
9308 
9310 {
9311  if (!spell)
9312  return;
9313 
9314  if (spell->m_appliedMods.empty())
9315  return;
9316 
9317  const SpellInfo* const spellInfo = spell->m_spellInfo;
9318 
9319  for (uint8 i = 0; i < MAX_SPELLMOD; ++i)
9320  {
9321  for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
9322  {
9323  SpellModifier* mod = *itr;
9324  ++itr;
9325 
9326  // spellmods without aura set cannot be charged
9327  if (!mod->ownerAura || !mod->ownerAura->IsUsingCharges())
9328  continue;
9329 
9330  // check if mod affected this spell
9331  Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
9332  if (iterMod == spell->m_appliedMods.end())
9333  continue;
9334 
9335  // remove from list
9336  // leave this here, if spell have two mods it will remove 2 charges - wrong
9337  spell->m_appliedMods.erase(iterMod);
9338 
9339  // MAGE T8P4 BONUS
9340  if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE )
9341  {
9342  const SpellInfo* sp = mod->ownerAura->GetSpellInfo();
9343  // Missile Barrage, Hot Streak, Brain Freeze (trigger spell - Fireball!)
9344  if( sp->SpellIconID == 3261 || sp->SpellIconID == 2999 || sp->SpellIconID == 2938 )
9345  if( AuraEffect* aurEff = GetAuraEffectDummy(64869) )
9346  if( roll_chance_i(aurEff->GetAmount()) )
9347  {
9348  mod->charges = 1;
9349  continue;
9350  }
9351  }
9352 
9354  itr = m_spellMods[i].begin();
9355  }
9356  }
9357 }
9358 
9360 {
9361  // don't handle spells with proc_event entry defined
9362  // this is a temporary workaround, because all spellmods should be handled like that
9363  if (sSpellMgr->GetSpellProcEvent(mod->spellId))
9364  return;
9365 
9366  if (spell && mod->ownerAura && mod->charges > 0)
9367  {
9368  if (--mod->charges == 0)
9369  mod->charges = -1;
9370 
9371  spell->m_appliedMods.insert(mod->ownerAura);
9372  }
9373 }
9374 
9376 {
9377  if (apply && m_spellModTakingSpell != nullptr)
9378  {
9379  LOG_INFO("misc", "Player::SetSpellModTakingSpell (A1) - %u, %u", spell->m_spellInfo->Id, m_spellModTakingSpell->m_spellInfo->Id);
9380  return;
9381  //ASSERT(m_spellModTakingSpell == nullptr);
9382  }
9383  else if (!apply)
9384  {
9385  if (!m_spellModTakingSpell)
9386  LOG_INFO("misc", "Player::SetSpellModTakingSpell (B1) - %u", spell->m_spellInfo->Id);
9387  else if (m_spellModTakingSpell != spell)
9388  {
9389  LOG_INFO("misc", "Player::SetSpellModTakingSpell (C1) - %u, %u", spell->m_spellInfo->Id, m_spellModTakingSpell->m_spellInfo->Id);
9390  return;
9391  }
9392  //ASSERT(m_spellModTakingSpell && m_spellModTakingSpell == spell);
9393  }
9394 
9395  m_spellModTakingSpell = apply ? spell : nullptr;
9396 }
9397 
9398 // send Proficiency
9399 void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask)
9400 {
9401  WorldPacket data(SMSG_SET_PROFICIENCY, 1 + 4);
9402  data << uint8(itemClass) << uint32(itemSubclassMask);
9403  GetSession()->SendPacket(&data);
9404 }
9405 
9407 {
9408  SignatureContainer* signatureStore = sPetitionMgr->GetSignatureStore();
9409  for (SignatureContainer::iterator itr = signatureStore->begin(); itr != signatureStore->end(); ++itr)
9410  {
9411  SignatureMap::iterator signItr = itr->second.signatureMap.find(guid);
9412  if (signItr != itr->second.signatureMap.end())
9413  {
9414  Petition const* petition = sPetitionMgr->GetPetition(itr->first);
9415  if (!petition || (type != 10 && type != petition->petitionType))
9416  continue;
9417 
9418  // erase this
9419  itr->second.signatureMap.erase(signItr);
9420 
9421  // send update if charter owner in game
9423  if (owner)
9424  owner->GetSession()->SendPetitionQueryOpcode(petition->petitionGuid);
9425  }
9426  }
9427 
9428  if (type == 10)
9429  {
9431  stmt->setUInt32(0, guid.GetCounter());
9432  CharacterDatabase.Execute(stmt);
9433  }
9434  else
9435  {
9437  stmt->setUInt32(0, guid.GetCounter());
9438  stmt->setUInt8(1, uint8(type));
9439  CharacterDatabase.Execute(stmt);
9440  }
9441 
9442  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
9443  if (type == 10)
9444  {
9446  stmt->setUInt32(0, guid.GetCounter());
9447  trans->Append(stmt);
9448 
9449  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER);
9450  stmt->setUInt32(0, guid.GetCounter());
9451  trans->Append(stmt);
9452 
9453  // xinef: clear petition store
9454  sPetitionMgr->RemovePetitionByOwnerAndType(guid, 0);
9455  }
9456  else
9457  {
9459  stmt->setUInt32(0, guid.GetCounter());
9460  stmt->setUInt8(1, uint8(type));
9461  trans->Append(stmt);
9462 
9464  stmt->setUInt32(0, guid.GetCounter());
9465  stmt->setUInt8(1, uint8(type));
9466  trans->Append(stmt);
9467 
9468  // xinef: clear petition store
9469  sPetitionMgr->RemovePetitionByOwnerAndType(guid, uint8(type));
9470  }
9471  CharacterDatabase.CommitTransaction(trans);
9472 }
9473 
9475 {
9476  // xinef: zomg! sync query
9478  stmt->setUInt32(0, guid.GetCounter());
9479  PreparedQueryResult result = CharacterDatabase.Query(stmt);
9480 
9481  if (!result)
9482  return;
9483 
9484  do
9485  {
9486  Field* fields = result->Fetch();
9487  uint32 arenaTeamId = fields[0].GetUInt32();
9488  if (arenaTeamId != 0)
9489  {
9490  ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
9491  if (arenaTeam)
9492  arenaTeam->DelMember(guid, true);
9493  }
9494  } while (result->NextRow());
9495 }
9496 
9497 void Player::SetRestBonus(float rest_bonus_new)
9498 {
9499  // Prevent resting on max level
9500  if (getLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
9501  rest_bonus_new = 0;
9502 
9503  if (rest_bonus_new < 0)
9504  rest_bonus_new = 0;
9505 
9506  float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * 1.5f / 2;
9507 
9508  if (rest_bonus_new > rest_bonus_max)
9509  _restBonus = rest_bonus_max;
9510  else
9511  _restBonus = rest_bonus_new;
9512 
9513  // update data for client
9514  if ((GetsRecruitAFriendBonus(true) && (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0)))
9516  else
9517  {
9518  if (_restBonus > 10)
9520  else if (_restBonus <= 1)
9522  }
9523 
9524  //RestTickUpdate
9526 }
9527 
9528 bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc /*= nullptr*/, uint32 spellid /*= 1*/)
9529 {
9530  if (nodes.size() < 2)
9531  return false;
9532 
9533  // not let cheating with start flight in time of logout process || while in combat || has type state: stunned || has type state: root
9535  {
9537  return false;
9538  }
9539 
9541  return false;
9542 
9543  // taximaster case
9544  if (npc)
9545  {
9546  // not let cheating with start flight mounted
9547  if (IsMounted())
9548  {
9550  return false;
9551  }
9552 
9554  {
9556  return false;
9557  }
9558 
9559  // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi
9560  if (IsNonMeleeSpellCast(false))
9561  {
9563  return false;
9564  }
9565  }
9566  // cast case or scripted call case
9567  else
9568  {
9570 
9573 
9575  if (spell->m_spellInfo->Id != spellid)
9577 
9579 
9581  if (spell->m_spellInfo->Id != spellid)
9583  }
9584 
9585  uint32 sourcenode = nodes[0];
9586 
9587  // starting node too far away (cheat?)
9588  TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(sourcenode);
9589  if (!node)
9590  {
9592  return false;
9593  }
9594 
9595  // check node starting pos data set case if provided
9596  if (node->x != 0.0f || node->y != 0.0f || node->z != 0.0f)
9597  {
9598  if (node->map_id != GetMapId() ||
9599  (node->x - GetPositionX()) * (node->x - GetPositionX()) +
9600  (node->y - GetPositionY()) * (node->y - GetPositionY()) +
9601  (node->z - GetPositionZ()) * (node->z - GetPositionZ()) >
9603  {
9605  return false;
9606  }
9607  }
9608  // node must have pos if taxi master case (npc != nullptr)
9609  else if (npc)
9610  {
9612  return false;
9613  }
9614 
9615  // Prepare to flight start now
9616 
9617  // stop combat at start taxi flight if any
9618  CombatStop();
9619 
9620  StopCastingCharm();
9622  ExitVehicle();
9623 
9624  // stop trade (client cancel trade at taxi map open but cheating tools can be used for reopen it)
9625  TradeCancel(true);
9626 
9627  // clean not finished taxi path if any
9629 
9630  // 0 element current node
9631  m_taxi.AddTaxiDestination(sourcenode);
9632 
9633  // fill destinations path tail
9634  uint32 sourcepath = 0;
9635  uint32 totalcost = 0;
9636 
9637  uint32 prevnode = sourcenode;
9638  uint32 lastnode = 0;
9639 
9640  for (uint32 i = 1; i < nodes.size(); ++i)
9641  {
9642  uint32 path, cost;
9643 
9644  lastnode = nodes[i];
9645  sObjectMgr->GetTaxiPath(prevnode, lastnode, path, cost);
9646 
9647  if (!path)
9648  {
9650  return false;
9651  }
9652 
9653  totalcost += cost;
9654 
9655  if (prevnode == sourcenode)
9656  sourcepath = path;
9657 
9658  m_taxi.AddTaxiDestination(lastnode);
9659 
9660  prevnode = lastnode;
9661  }
9662 
9663  // get mount model (in case non taximaster (npc == nullptr) allow more wide lookup)
9664  //
9665  // Hack-Fix for Alliance not being able to use Acherus taxi. There is
9666  // only one mount ID for both sides. Probably not good to use 315 in case DBC nodes
9667  // change but I couldn't find a suitable alternative. OK to use class because only DK
9668  // can use this taxi.
9669  uint32 mount_display_id = sObjectMgr->GetTaxiMountDisplayId(sourcenode, GetTeamId(true), npc == nullptr || (sourcenode == 315 && getClass() == CLASS_DEATH_KNIGHT));
9670 
9671  // in spell case allow 0 model
9672  if ((mount_display_id == 0 && spellid == 0) || sourcepath == 0)
9673  {
9676  return false;
9677  }
9678 
9679  uint32 money = GetMoney();
9680 
9681  if (npc)
9682  totalcost = (uint32)ceil(totalcost * GetReputationPriceDiscount(npc));
9683 
9684  if (money < totalcost)
9685  {
9688  return false;
9689  }
9690 
9691  //Checks and preparations done, DO FLIGHT
9693  ModifyMoney(-(int32)totalcost);
9695 
9696  // prevent stealth flight
9697  //RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
9698 
9699  // Xinef: dont use instant flight paths if spellid is present (custom calls use spellid = 1)
9700  if ((sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 1 || (sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 2 && m_isInstantFlightOn)) && !spellid)
9701  {
9702  TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size() - 1]);
9704  TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation());
9705  return false;
9706  }
9707  else
9708  {
9709  m_flightSpellActivated = spellid;
9711  GetSession()->SendDoFlight(mount_display_id, sourcepath);
9712  }
9713  return true;
9714 }
9715 
9716 bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 1*/)
9717 {
9718  TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(taxi_path_id);
9719  if (!entry)
9720  return false;
9721 
9722  std::vector<uint32> nodes;
9723 
9724  nodes.resize(2);
9725  nodes[0] = entry->from;
9726  nodes[1] = entry->to;
9727 
9728  return ActivateTaxiPathTo(nodes, nullptr, spellid);
9729 }
9730 
9732 {
9733  // For spells that trigger flying paths remove them at arrival
9735  {
9738  }
9739  m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
9740  Dismount();
9743 }
9744 
9746 {
9747  uint32 sourceNode = m_taxi.GetTaxiSource();
9748  if (!sourceNode)
9749  return;
9750 
9751  LOG_DEBUG("entities.unit", "WORLD: Restart character %s taxi flight", GetGUID().ToString().c_str());
9752 
9753  uint32 mountDisplayId = sObjectMgr->GetTaxiMountDisplayId(sourceNode, GetTeamId(true), true);
9754  if (!mountDisplayId)
9755  return;
9756 
9757  uint32 path = m_taxi.GetCurrentTaxiPath();
9758 
9759  // search appropriate start path node
9760  uint32 startNode = 0;
9761 
9762  TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];
9763 
9764  float bestDist = SIZE_OF_GRIDS * SIZE_OF_GRIDS; // xinef: large value
9765  float currDist = 0.0f;
9766 
9767  // xinef: changed to -1, we dont want to catch last node
9768  for (uint32 i = 0; i < nodeList.size() - 1; ++i)
9769  {
9770  TaxiPathNodeEntry const* node = nodeList[i];
9771  TaxiPathNodeEntry const* nextNode = nodeList[i + 1];
9772 
9773  // xinef: skip nodes at another map, get last valid node on current map
9774  if (nextNode->mapid != GetMapId() || node->mapid != GetMapId())
9775  continue;
9776 
9777  currDist = (node->x - GetPositionX()) * (node->x - GetPositionX()) + (node->y - GetPositionY()) * (node->y - GetPositionY()) + (node->z - GetPositionZ()) * (node->z - GetPositionZ());
9778  if (currDist < bestDist)
9779  {
9780  startNode = i;
9781  bestDist = currDist;
9782  }
9783  }
9784 
9785  // xinef: no proper node was found
9786  if (startNode == 0)
9787  {
9789  return;
9790  }
9791 
9793  {
9795  }
9796 
9797  if (IsMounted())
9798  {
9800  }
9801 
9802  GetSession()->SendDoFlight(mountDisplayId, path, startNode);
9803 }
9804 
9806 {
9807  PacketCooldowns cooldowns;
9808  WorldPacket data;
9809 
9810  for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
9811  {
9812  if (itr->second->State == PLAYERSPELL_REMOVED)
9813  continue;
9814  uint32 unSpellId = itr->first;
9815  SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(unSpellId);
9816 
9817  // Not send cooldown for this spells
9818  if (spellInfo->IsCooldownStartedOnEvent())
9819  continue;
9820 
9822  continue;
9823 
9824  if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetSpellCooldownDelay(unSpellId) < unTimeMs)
9825  {
9826  cooldowns[unSpellId] = unTimeMs;
9827  AddSpellCooldown(unSpellId, 0, unTimeMs, true);
9828  }
9829  }
9830 
9831  if (!cooldowns.empty())
9832  {
9834  GetSession()->SendPacket(&data);
9835  }
9836 }
9837 
9838 void Player::InitDataForForm(bool reapplyMods)
9839 {
9841 
9842  SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
9843  if (ssEntry && ssEntry->attackSpeed)
9844  {
9848  }
9849  else
9851 
9852  switch (form)
9853  {
9854  case FORM_GHOUL:
9855  case FORM_CAT:
9856  {
9857  if (getPowerType() != POWER_ENERGY)
9859  break;
9860  }
9861  case FORM_BEAR:
9862  case FORM_DIREBEAR:
9863  {
9864  if (getPowerType() != POWER_RAGE)
9866  break;
9867  }
9868  default: // 0, for example
9869  {
9870  ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
9871  if (cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType)
9872  setPowerType(Powers(cEntry->powerType));
9873  break;
9874  }
9875  }
9876 
9877  // update auras at form change, ignore this at mods reapply (.reset stats/etc) when form not change.
9878  if (!reapplyMods)
9880 
9883 }
9884 
9886 {
9887  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(true), getClass());
9888  if (!info)
9889  {
9890  LOG_ERROR("entities.player", "Player %s has incorrect race/class pair. Can't init display ids.", GetGUID().ToString().c_str());
9891  return;
9892  }
9893 
9894  uint8 gender = getGender();
9895  switch (gender)
9896  {
9897  case GENDER_FEMALE:
9898  SetDisplayId(info->displayId_f);
9900  break;
9901  case GENDER_MALE:
9902  SetDisplayId(info->displayId_m);
9904  break;
9905  default:
9906  LOG_ERROR("entities.player", "Invalid gender %u for player", gender);
9907  return;
9908  }
9909 }
9910 
9911 inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore)
9912 {
9913  ItemPosCountVec vDest;
9914  uint16 uiDest = 0;
9915  InventoryResult msg = bStore ?
9916  CanStoreNewItem(bag, slot, vDest, item, pProto->BuyCount * count) :
9917  CanEquipNewItem(slot, uiDest, item, false);
9918  if (msg != EQUIP_ERR_OK)
9919  {
9920  SendEquipError(msg, nullptr, nullptr, item);
9921  return false;
9922  }
9923 
9924  ModifyMoney(-price);
9925 
9926  if (crItem->ExtendedCost) // case for new honor system
9927  {
9928  ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
9929  if (iece->reqhonorpoints)
9930  ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
9931 
9932  if (iece->reqarenapoints)
9933  ModifyArenaPoints(- int32(iece->reqarenapoints * count));
9934 
9935  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
9936  {
9937  if (iece->reqitem[i])
9938  DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
9939  }
9940  }
9941 
9942  sScriptMgr->OnBeforeStoreOrEquipNewItem(this, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore);
9943 
9944  Item* it = bStore ? StoreNewItem(vDest, item, true) : EquipNewItem(uiDest, item, true);
9945  if (it)
9946  {
9947  uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem, pProto->BuyCount * count);
9948 
9949  WorldPacket data(SMSG_BUY_ITEM, (8 + 4 + 4 + 4));
9950  data << pVendor->GetGUID();
9951  data << uint32(vendorslot + 1); // numbered from 1 at client
9952  data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF);
9953  data << uint32(count);
9954  GetSession()->SendPacket(&data);
9955  SendNewItem(it, pProto->BuyCount * count, true, false, false);
9956 
9957  if (!bStore)
9959 
9960  if (pProto->Flags & ITEM_FLAG_ITEM_PURCHASE_RECORD && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
9961  {
9963  it->SetRefundRecipient(GetGUID().GetCounter());
9964  it->SetPaidMoney(price);
9965  it->SetPaidExtendedCost(crItem->ExtendedCost);
9966  it->SaveRefundDataToDB();
9967  AddRefundReference(it->GetGUID());
9968  }
9969  }
9970 
9971  sScriptMgr->OnAfterStoreOrEquipNewItem(this, vendorslot, it, count, bag, slot, pProto, pVendor, crItem, bStore);
9972 
9973  return true;
9974 }
9975 
9976 // Return true is the bought item has a max count to force refresh of window by caller
9977 bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
9978 {
9979  sScriptMgr->OnBeforeBuyItemFromVendor(this, vendorguid, vendorslot, item, count, bag, slot);
9980 
9981  // this check can be used from the hook to implement a custom vendor process
9982  if (item == 0)
9983  return true;
9984 
9985  // cheating attempt
9986  if (count < 1) count = 1;
9987 
9988  // cheating attempt
9989  if (slot > MAX_BAG_SIZE && slot != NULL_SLOT)
9990  return false;
9991 
9992  if (!IsAlive())
9993  return false;
9994 
9995  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
9996  if (!pProto)
9997  {
9998  SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0);
9999  return false;
10000  }
10001 
10002  if (!(pProto->AllowableClass & getClassMask()) && pProto->Bonding == BIND_WHEN_PICKED_UP && !IsGameMaster())
10003  {
10004  SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0);
10005  return false;
10006  }
10007 
10009  {
10010  return false;
10011  }
10012 
10013  Creature* creature = GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
10014  if (!creature)
10015  {
10016  LOG_DEBUG("network", "WORLD: BuyItemFromVendor - Unit (%s) not found or you can't interact with him.", vendorguid.ToString().c_str());
10017  SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item, 0);
10018  return false;
10019  }
10020 
10021  ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(creature->GetEntry(), item);
10022  if (!sConditionMgr->IsObjectMeetToConditions(this, creature, conditions))
10023  {
10024  //TC_LOG_DEBUG("condition", "BuyItemFromVendor: conditions not met for creature entry %u item %u", creature->GetEntry(), item);
10025  SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
10026  return false;
10027  }
10028 
10029  VendorItemData const* vItems = GetSession()->GetCurrentVendor() ? sObjectMgr->GetNpcVendorItemList(GetSession()->GetCurrentVendor()) : creature->GetVendorItems();
10030  if (!vItems || vItems->Empty())
10031  {
10032  SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
10033  return false;
10034  }
10035 
10036  if (vendorslot >= vItems->GetItemCount())
10037  {
10038  SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
10039  return false;
10040  }
10041 
10042  VendorItem const* crItem = vItems->GetItem(vendorslot);
10043  // store diff item (cheating)
10044  if (!crItem || crItem->item != item)
10045  {
10046  SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
10047  return false;
10048  }
10049 
10050  // check current item amount if it limited
10051  if (crItem->maxcount != 0)
10052  {
10053  if (creature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count)
10054  {
10055  SendBuyError(BUY_ERR_ITEM_ALREADY_SOLD, creature, item, 0);
10056  return false;
10057  }
10058  }
10059 
10061  {
10062  SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, item, 0);
10063  return false;
10064  }
10065 
10066  if (crItem->ExtendedCost)
10067  {
10068  ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
10069  if (!iece)
10070  {
10071  LOG_ERROR("entities.player", "Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
10072  return false;
10073  }
10074 
10075  // honor points price
10076  if (GetHonorPoints() < (iece->reqhonorpoints * count))
10077  {
10079  return false;
10080  }
10081 
10082  // arena points price
10083  if (GetArenaPoints() < (iece->reqarenapoints * count))
10084  {
10086  return false;
10087  }
10088 
10089  // item base price
10090  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
10091  {
10092  if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
10093  {
10095  return false;
10096  }
10097  }
10098 
10099  // check for personal arena rating requirement
10101  {
10102  // probably not the proper equip err
10103  SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, nullptr, nullptr);
10104  return false;
10105  }
10106  }
10107 
10108  uint32 price = 0;
10109  if (crItem->IsGoldRequired(pProto) && pProto->BuyPrice > 0) //Assume price cannot be negative (do not know why it is int32)
10110  {
10111  uint32 maxCount = MAX_MONEY_AMOUNT / pProto->BuyPrice;
10112  if ((uint32)count > maxCount)
10113  {
10114  LOG_ERROR("entities.player", "Player %s tried to buy %u item id %u, causing overflow", GetName().c_str(), (uint32)count, pProto->ItemId);
10115  count = (uint8)maxCount;
10116  }
10117  price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT
10118 
10119  // reputation discount
10120  price = uint32(floor(price * GetReputationPriceDiscount(creature)));
10121 
10122  if (!HasEnoughMoney(price))
10123  {
10124  SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, item, 0);
10125  return false;
10126  }
10127  }
10128 
10129  if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
10130  {
10131  if (!_StoreOrEquipNewItem(vendorslot, item, count, bag, slot, price, pProto, creature, crItem, true))
10132  return false;
10133  }
10134  else if (IsEquipmentPos(bag, slot))
10135  {
10136  if (pProto->BuyCount * count != 1)
10137  {
10139  return false;
10140  }
10141  if (!_StoreOrEquipNewItem(vendorslot, item, count, bag, slot, price, pProto, creature, crItem, false))
10142  return false;
10143  }
10144  else
10145  {
10147  return false;
10148  }
10149 
10150  return crItem->maxcount != 0;
10151 }
10152 
10154 {
10155  // returns the maximal personal arena rating that can be used to purchase items requiring this condition
10156  // the personal rating of the arena team must match the required limit as well
10157  // so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype]))
10158  uint32 max_personal_rating = 0;
10159  for (uint8 i = minarenaslot; i < MAX_ARENA_SLOT; ++i)
10160  {
10161  if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamId(i)))
10162  {
10163  uint32 p_rating = GetArenaPersonalRating(i);
10164  uint32 t_rating = at->GetRating();
10165  p_rating = p_rating < t_rating ? p_rating : t_rating;
10166  if (max_personal_rating < p_rating)
10167  max_personal_rating = p_rating;
10168  }
10169  }
10170 
10171  sScriptMgr->OnGetMaxPersonalArenaRatingRequirement(this, minarenaslot, max_personal_rating);
10172 
10173  return max_personal_rating;
10174 }
10175 
10176 void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell, bool infinityCooldown)
10177 {
10178  // init cooldown values
10179  uint32 cat = 0;
10180  int32 rec = -1;
10181  int32 catrec = -1;
10182 
10183  // some special item spells without correct cooldown in SpellInfo
10184  // cooldown information stored in item prototype
10185  // This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client.
10186 
10187  if (itemId)
10188  {
10189  if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))
10190  {
10191  for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx)
10192  {
10193  if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id)
10194  {
10195  cat = proto->Spells[idx].SpellCategory;
10196  rec = proto->Spells[idx].SpellCooldown;
10197  catrec = proto->Spells[idx].SpellCategoryCooldown;
10198  break;
10199  }
10200  }
10201  }
10202  }
10203 
10204  // if no cooldown found above then base at DBC data
10205  if (rec < 0 && catrec < 0)
10206  {
10207  cat = spellInfo->GetCategory();
10208  rec = spellInfo->RecoveryTime;
10209  catrec = spellInfo->CategoryRecoveryTime;
10210  }
10211 
10212  time_t catrecTime;
10213  time_t recTime;
10214 
10215  bool needsCooldownPacket = false;
10216  bool useSpellCooldown = false;
10217 
10218  // overwrite time for selected category
10219  if (infinityCooldown)
10220  {
10221  // use +MONTH as infinity mark for spell cooldown (will checked as MONTH/2 at save ans skipped)
10222  // but not allow ignore until reset or re-login
10223  catrecTime = catrec > 0 ? infinityCooldownDelay : 0;
10224  recTime = rec > 0 ? infinityCooldownDelay : catrecTime;
10225  }
10226  else
10227  {
10228  // shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK)
10229  // prevent 0 cooldowns set by another way
10230  if (rec <= 0 && catrec <= 0 && (cat == 76 || (spellInfo->IsAutoRepeatRangedSpell() && spellInfo->Id != 75)))
10232 
10233  // Now we have cooldown data (if found any), time to apply mods
10234  if (rec > 0)
10235  {
10236  int32 oldRec = rec;
10237  ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, rec, spell);
10238  if (oldRec != rec)
10239  {
10240  useSpellCooldown = true;
10241  }
10242  }
10243 
10244  if (catrec > 0 && !spellInfo->HasAttribute(SPELL_ATTR6_NO_CATEGORY_COOLDOWN_MODS))
10245  {
10246  ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, catrec, spell);
10247  }
10248 
10250  {
10251  // Apply SPELL_AURA_MOD_COOLDOWN only to own spells
10252  if (HasSpell(spellInfo->Id))
10253  {
10254  needsCooldownPacket = true;
10255  useSpellCooldown = true;
10256  rec += cooldownMod * IN_MILLISECONDS; // SPELL_AURA_MOD_COOLDOWN does not affect category cooldows, verified with shaman shocks
10257  }
10258  }
10259 
10260  // replace negative cooldowns by 0
10261  if (rec < 0) rec = 0;
10262  if (catrec < 0) catrec = 0;
10263 
10264  // no cooldown after applying spell mods
10265  if (rec == 0 && catrec == 0)
10266  return;
10267 
10268  catrecTime = catrec ? catrec : 0;
10269  recTime = rec ? rec : catrecTime;
10270  }
10271 
10272  // category spells
10273  if (cat && catrec > 0)
10274  {
10275  _AddSpellCooldown(spellInfo->Id, cat, itemId, useSpellCooldown? recTime : catrecTime, true, true);
10276  if (needsCooldownPacket)
10277  {
10278  WorldPacket data;
10279  BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, spellInfo->Id, useSpellCooldown ? recTime : catrecTime);
10280  SendDirectMessage(&data);
10281  }
10282 
10283  SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(cat);
10284  if (i_scstore != sSpellsByCategoryStore.end())
10285  {
10286  for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
10287  {
10288  if (i_scset->second == spellInfo->Id) // skip main spell, already handled above
10289  {
10290  continue;
10291  }
10292 
10293  // If spell category is applied by item, then other spells should be exists in item templates
10294  if ((itemId > 0) != i_scset->first)
10295  {
10296  continue;
10297  }
10298 
10299  // Only within the same spellfamily
10300  SpellInfo const* categorySpellInfo = sSpellMgr->GetSpellInfo(i_scset->second);
10301  if (!categorySpellInfo || categorySpellInfo->SpellFamilyName != spellInfo->SpellFamilyName)
10302  {
10303  continue;
10304  }
10305 
10306  _AddSpellCooldown(i_scset->second, cat, itemId, catrecTime, !spellInfo->IsCooldownStartedOnEvent() && catrec && rec && catrec != rec);
10307  }
10308  }
10309  }
10310  else
10311  {
10312  // self spell cooldown
10313  if (recTime > 0)
10314  {
10315  _AddSpellCooldown(spellInfo->Id, 0, itemId, recTime, true, true);
10316 
10317  if (needsCooldownPacket)
10318  {
10319  WorldPacket data;
10320  BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, spellInfo->Id, rec);
10321  SendDirectMessage(&data);
10322  }
10323  }
10324  }
10325 }
10326 
10327 void Player::_AddSpellCooldown(uint32 spellid, uint16 categoryId, uint32 itemid, uint32 end_time, bool needSendToClient, bool forceSendToSpectator)
10328 {
10329  SpellCooldown sc;
10330  sc.end = World::GetGameTimeMS() + end_time;
10331  sc.category = categoryId;
10332  sc.itemid = itemid;
10333  sc.maxduration = end_time;
10334  sc.sendToSpectator = false;
10335  sc.needSendToClient = needSendToClient;
10336 
10338  {
10339  if (NeedSendSpectatorData() && forceSendToSpectator && (itemid || HasActiveSpell(spellid)))
10340  {
10341  sc.sendToSpectator = true;
10342  ArenaSpectator::SendCommand_Cooldown(FindMap(), GetGUID(), "ACD", spellid, end_time / IN_MILLISECONDS, end_time / IN_MILLISECONDS);
10343  }
10344  }
10345 
10346  m_spellCooldowns[spellid] = std::move(sc);
10347 }
10348 
10349 void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, uint32 end_time, bool needSendToClient, bool forceSendToSpectator)
10350 {
10351  _AddSpellCooldown(spellid, 0, itemid, end_time, needSendToClient, forceSendToSpectator);
10352 }
10353 
10355 {
10356  SpellCooldowns::iterator itr = m_spellCooldowns.find(spellId);
10357  if (itr == m_spellCooldowns.end())
10358  return;
10359 
10360  itr->second.end += cooldown;
10361 
10362  WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4);
10363  data << uint32(spellId); // Spell ID
10364  data << GetGUID(); // Player GUID
10365  data << int32(cooldown); // Cooldown mod in milliseconds
10366  GetSession()->SendPacket(&data);
10367 }
10368 
10369 void Player::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= nullptr*/, bool setCooldown /*= true*/)
10370 {
10371  // start cooldowns at server side, if any
10372  if (setCooldown)
10373  AddSpellAndCategoryCooldowns(spellInfo, itemId, spell);
10374 
10375  // Send activate cooldown timer (possible 0) at client side
10376  WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
10377  data << uint32(spellInfo->Id);
10378  data << GetGUID();
10379  SendDirectMessage(&data);
10380 }
10381 
10382 //slot to be excluded while counting
10383 bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot)
10384 {
10385  if (!enchantmentcondition)
10386  return true;
10387 
10388  SpellItemEnchantmentConditionEntry const* Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition);
10389 
10390  if (!Condition)
10391  return true;
10392 
10393  uint8 curcount[4] = {0, 0, 0, 0};
10394 
10395  //counting current equipped gem colors
10396  for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
10397  {
10398  if (i == slot)
10399  continue;
10400  Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i);
10401  if (pItem2 && !pItem2->IsBroken() && pItem2->HasSocket())
10402  {
10403  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot <= PRISMATIC_ENCHANTMENT_SLOT; ++enchant_slot)
10404  {
10405  if (enchant_slot == BONUS_ENCHANTMENT_SLOT)
10406  continue;
10407 
10408  uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot));
10409  if (!enchant_id)
10410  continue;
10411 
10412  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
10413  if (!enchantEntry)
10414  continue;
10415 
10416  uint32 gemid = enchantEntry->GemID;
10417  if (!gemid)
10418  continue;
10419 
10420  ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemid);
10421  if (!gemProto)
10422  continue;
10423 
10424  GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties);
10425  if (!gemProperty)
10426  continue;
10427 
10428  uint8 GemColor = gemProperty->color;
10429 
10430  for (uint8 b = 0, tmpcolormask = 1; b < 4; b++, tmpcolormask <<= 1)
10431  {
10432  if (tmpcolormask & GemColor)
10433  ++curcount[b];
10434  }
10435  }
10436  }
10437  }
10438 
10439  bool activate = true;
10440 
10441  for (uint8 i = 0; i < 5; i++)
10442  {
10443  if (!Condition->Color[i])
10444  continue;
10445 
10446  uint32 _cur_gem = curcount[Condition->Color[i] - 1];
10447 
10448  // if have <CompareColor> use them as count, else use <value> from Condition
10449  uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1] : Condition->Value[i];
10450 
10451  switch (Condition->Comparator[i])
10452  {
10453  case 2: // requires less <color> than (<value> || <comparecolor>) gems
10454  activate &= (_cur_gem < _cmp_gem);
10455  break;
10456  case 3: // requires more <color> than (<value> || <comparecolor>) gems
10457  activate &= (_cur_gem > _cmp_gem);
10458  break;
10459  case 5: // requires at least <color> than (<value> || <comparecolor>) gems
10460  activate &= (_cur_gem >= _cmp_gem);
10461  break;
10462  }
10463  }
10464 
10465  LOG_DEBUG("entities.player.items", "Checking Condition %u, there are %u Meta Gems, %u Red Gems, %u Yellow Gems and %u Blue Gems, Activate:%s", enchantmentcondition, curcount[0], curcount[1], curcount[2], curcount[3], activate ? "yes" : "no");
10466 
10467  return activate;
10468 }
10469 
10471 {
10472  //cycle all equipped items
10473  for (uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
10474  {
10475  //enchants for the slot being socketed are handled by Player::ApplyItemMods
10476  if (slot == exceptslot)
10477  continue;
10478 
10479  Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
10480 
10481  if (!pItem || !pItem->HasSocket())
10482  continue;
10483 
10484  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)
10485  {
10486  uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot));
10487  if (!enchant_id)
10488  continue;
10489 
10490  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
10491  if (!enchantEntry)
10492  continue;
10493 
10494  uint32 condition = enchantEntry->EnchantmentCondition;
10495  if (condition)
10496  {
10497  //was enchant active with/without item?
10498  bool wasactive = EnchantmentFitsRequirements(condition, apply ? exceptslot : -1);
10499  //should it now be?
10500  if (wasactive ^ EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot))
10501  {
10502  // ignore item gem conditions
10503  //if state changed, (dis)apply enchant
10504  ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), !wasactive, true, true);
10505  }
10506  }
10507  }
10508  }
10509 }
10510 
10511 //if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements
10513 {
10514  //cycle all equipped items
10515  for (int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
10516  {
10517  //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recvData)
10518  if (slot == exceptslot)
10519  continue;
10520 
10521  Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
10522 
10523  if (!pItem || !pItem->GetTemplate()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item
10524  continue;
10525 
10526  //cycle all (gem)enchants
10527  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)
10528  {
10529  uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot));
10530  if (!enchant_id) //if no enchant go to next enchant(slot)
10531  continue;
10532 
10533  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
10534  if (!enchantEntry)
10535  continue;
10536 
10537  //only metagems to be (de)activated, so only enchants with condition
10538  uint32 condition = enchantEntry->EnchantmentCondition;
10539  if (condition)
10540  ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), apply);
10541  }
10542  }
10543 }
10544 
10546 {
10549 
10550  if (!m_taxi.empty())
10551  {
10554 
10555  std::vector<uint32> const& taxi = m_taxi.GetPath();
10556  for (std::vector<uint32>::const_iterator itr = taxi.begin(); itr != taxi.end(); ++itr)
10557  m_entryPointData.taxiPath.push_back(*itr);
10558 
10560  }
10561  else
10562  {
10563  if (IsMounted())
10564  {
10566  if (!auras.empty())
10567  m_entryPointData.mountSpell = (*auras.begin())->GetId();
10568  }
10569  else
10571 
10572  if (GetMap()->IsDungeon())
10573  {
10574  if (const GraveyardStruct* entry = sGraveyard->GetClosestGraveyard(this, GetTeamId()))
10575  m_entryPointData.joinPos = WorldLocation(entry->Map, entry->x, entry->y, entry->z, 0.0f);
10576  }
10577  else if (!GetMap()->IsBattlegroundOrArena())
10579  }
10580 
10583 }
10584 
10586 {
10587  if (!bg)
10588  bg = GetBattleground();
10589 
10590  if (!bg)
10591  return;
10592 
10593  // Deserter tracker - leave BG
10594  if (bg->isBattleground() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
10595  {
10596  if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
10597  {
10599  stmt->setUInt32(0, GetGUID().GetCounter());
10601  CharacterDatabase.Execute(stmt);
10602  }
10603  sScriptMgr->OnBattlegroundDesertion(this, BG_DESERTION_TYPE_LEAVE_BG);
10604  }
10605 
10606  // xinef: reset corpse reclaim time
10607  m_deathExpireTime = time(nullptr);
10608 
10609  // pussywizard: clear movement, because after porting player will move to arena cords
10611  StopMoving();
10613 }
10614 
10616 {
10617  // check Deserter debuff
10618  if (HasAura(26013))
10619  return false;
10620 
10621  return true;
10622 }
10623 
10625 {
10626  // a player can complain about 15 people per 5 minutes
10627  if (m_bgData.bgAfkReportedCount++ >= 15)
10628  return false;
10629 
10630  return true;
10631 }
10632 
10635 {
10636  Battleground* bg = GetBattleground();
10637  // Battleground also must be in progress!
10638  if (!bg || bg != reporter->GetBattleground() || GetTeamId() != reporter->GetTeamId() || bg->GetStatus() != STATUS_IN_PROGRESS)
10639  return;
10640 
10641  // Xinef: 2 minutes startup + 2 minute of match
10643  return;
10644 
10645  // check if player has 'Idle' or 'Inactive' debuff
10646  if (m_bgData.bgAfkReporter.find(reporter->GetGUID()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit())
10647  {
10648  m_bgData.bgAfkReporter.insert(reporter->GetGUID());
10649  // by default 3 players have to complain to apply debuff
10650  if (m_bgData.bgAfkReporter.size() >= sWorld->getIntConfig(CONFIG_BATTLEGROUND_REPORT_AFK))
10651  {
10652  // cast 'Idle' spell
10653  CastSpell(this, 43680, true);
10654  m_bgData.bgAfkReporter.clear();
10655  }
10656  }
10657 }
10658 
10660 {
10661  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(true), getClass());
10662  uint32 mapId = info->mapId;
10663  if (getClass() == CLASS_DEATH_KNIGHT && HasSpell(50977))
10664  return WorldLocation(0, 2352.0f, -5709.0f, 154.5f, 0.0f);
10665  return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0);
10666 }
10667 
10669 {
10670  if (Unit::IsNeverVisible())
10671  return true;
10672 
10673  if (GetSession()->PlayerLogout() || GetSession()->PlayerLoading())
10674  return true;
10675 
10676  return false;
10677 }
10678 
10679 bool Player::CanAlwaysSee(WorldObject const* obj) const
10680 {
10681  // Always can see self
10682  if (m_mover == obj)
10683  return true;
10684 
10686  if (obj->GetGUID() == guid)
10687  return true;
10688 
10689  return false;
10690 }
10691 
10693 {
10694  if (Unit::IsAlwaysDetectableFor(seer))
10695  return true;
10696 
10697  if (const Player* seerPlayer = seer->ToPlayer())
10698  if (IsGroupVisibleFor(seerPlayer))
10699  return !(seerPlayer->duel && seerPlayer->duel->startTime != 0 && seerPlayer->duel->opponent == this);
10700 
10701  return false;
10702 }
10703 
10705 {
10706  if (!u)
10707  return false;
10708 
10709  // Always can see self
10710  if (u == this)
10711  return true;
10712 
10713  // Visible units, always are visible for all players
10714  if (IsVisible())
10715  return true;
10716 
10717  // GMs are visible for higher gms (or players are visible for gms)
10719  return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity();
10720 
10721  if (!sScriptMgr->NotVisibleGloballyFor(const_cast<Player*>(this), u))
10722  return true;
10723 
10724  // non faction visibility non-breakable for non-GMs
10725  return false;
10726 }
10727 
10729 {
10731 }
10732 
10733 bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/)
10734 {
10735  if (!amount)
10736  return true;
10737 
10738  sScriptMgr->OnPlayerMoneyChanged(this, amount);
10739 
10740  if (amount < 0)
10741  SetMoney (GetMoney() > uint32(-amount) ? GetMoney() + amount : 0);
10742  else
10743  {
10744  if (GetMoney() < uint32(MAX_MONEY_AMOUNT - amount))
10745  SetMoney(GetMoney() + amount);
10746  else
10747  {
10748  if (sendError)
10749  SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, nullptr, nullptr);
10750  return false;
10751  }
10752  }
10753 
10754  return true;
10755 }
10756 
10758 {
10759  if (ObjectGuid selectionGUID = GetGuidValue(UNIT_FIELD_TARGET))
10760  return ObjectAccessor::GetUnit(*this, selectionGUID);
10761 
10762  return nullptr;
10763 }
10764 
10766 {
10767  if (ObjectGuid selectionGUID = GetGuidValue(UNIT_FIELD_TARGET))
10768  return ObjectAccessor::GetPlayer(*this, selectionGUID);
10769 
10770  return nullptr;
10771 }
10772 
10774 {
10776 
10777  if (NeedSendSpectatorData())
10779 }
10780 
10782 {
10783  Unit* combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget);
10784  if (combotarget)
10785  {
10786  WorldPacket data;
10787  if (m_mover != this)
10788  {
10789  data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, m_mover->GetPackGUID().size() + combotarget->GetPackGUID().size() + 1);
10790  data << m_mover->GetPackGUID();
10791  }
10792  else
10793  data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size() + 1);
10794  data << combotarget->GetPackGUID();
10795  data << uint8(m_comboPoints);
10796  GetSession()->SendPacket(&data);
10797  }
10798 }
10799 
10800 void Player::AddComboPoints(Unit* target, int8 count)
10801 {
10802  if (!count)
10803  return;
10804 
10805  int8* comboPoints = &m_comboPoints;
10806 
10807  // without combo points lost (duration checked in aura)
10809 
10810  if (target->GetGUID() == m_comboTarget)
10811  *comboPoints += count;
10812  else
10813  {
10814  if (m_comboTarget)
10815  if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTarget))
10816  target2->RemoveComboPointHolder(GetGUID());
10817 
10818  m_comboTarget = target->GetGUID();
10819  *comboPoints = count;
10820 
10821  target->AddComboPointHolder(GetGUID());
10822  }
10823 
10824  if (*comboPoints > 5)
10825  *comboPoints = 5;
10826  else if (*comboPoints < 0)
10827  *comboPoints = 0;
10828 
10829  SendComboPoints();
10830 }
10831 
10833 {
10834  if (!m_comboTarget)
10835  return;
10836 
10837  // without combopoints lost (duration checked in aura)
10839 
10840  m_comboPoints = 0;
10841 
10842  SendComboPoints();
10843 
10844  if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTarget))
10845  target->RemoveComboPointHolder(GetGUID());
10846 
10847  m_comboTarget.Clear();
10848 }
10849 
10850 void Player::SetGroup(Group* group, int8 subgroup)
10851 {
10852  if (group == nullptr)
10853  m_group.unlink();
10854  else
10855  {
10856  // never use SetGroup without a subgroup unless you specify nullptr for group
10857  ASSERT(subgroup >= 0);
10858  m_group.link(group, this);
10859  m_group.setSubGroup((uint8)subgroup);
10860  }
10861 
10862  UpdateObjectVisibility(false);
10863 }
10864 
10866 {
10869 
10870  // guild bank list wtf?
10871 
10872  // Homebind
10873  WorldPacket data(SMSG_BINDPOINTUPDATE, 5 * 4);
10874  data << m_homebindX << m_homebindY << m_homebindZ;
10875  data << (uint32) m_homebindMapId;
10876  data << (uint32) m_homebindAreaId;
10877  GetSession()->SendPacket(&data);
10878 
10879  // SMSG_SET_PROFICIENCY
10880  // SMSG_SET_PCT_SPELL_MODIFIER
10881  // SMSG_SET_FLAT_SPELL_MODIFIER
10882  // SMSG_UPDATE_AURA_DURATION
10883 
10884  SendTalentsInfoData(false);
10885 
10886  // SMSG_INSTANCE_DIFFICULTY
10887  data.Initialize(SMSG_INSTANCE_DIFFICULTY, 4 + 4);
10888  data << uint32(GetMap()->GetDifficulty());
10889  data << uint32(GetMap()->GetEntry()->IsDynamicDifficultyMap() && GetMap()->IsHeroic()); // Raid dynamic difficulty
10890  GetSession()->SendPacket(&data);
10891 
10893 
10895  data << uint32(0); // count, for (count) uint32;
10896  GetSession()->SendPacket(&data);
10897 
10901 
10903 
10904  data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
10905  data.AppendPackedTime(sWorld->GetGameTime());
10906  data << float(0.01666667f); // game speed
10907  data << uint32(0); // added in 3.1.2
10908  GetSession()->SendPacket(&data);
10909 
10910  GetReputationMgr().SendForceReactions(); // SMSG_SET_FORCED_REACTIONS
10911 
10912  // SMSG_TALENTS_INFO x 2 for pet (unspent points and talents in separate packets...)
10913  // SMSG_PET_GUIDS
10914  // SMSG_UPDATE_WORLD_STATE
10915  // SMSG_POWER_UPDATE
10916 
10917  SetMover(this);
10918 
10919  sScriptMgr->OnSendInitialPacketsBeforeAddToMap(this, data);
10920 }
10921 
10923 {
10925 
10927  GetSession()->SendTimeSync();
10928 
10929  CastSpell(this, 836, true); // LOGINEFFECT
10930 
10931  // set some aura effects that send packet to player client after add player to map
10932  // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply
10933  // same auras state lost at far teleport, send it one more time in this case also
10934  static const AuraType auratypes[] =
10935  {
10939  };
10940  for (AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr)
10941  {
10942  Unit::AuraEffectList const& auraList = GetAuraEffectsByType(*itr);
10943  if (!auraList.empty())
10944  auraList.front()->HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true);
10945  }
10946 
10947  // Fix mount shit... to tired to think, update block gets messed somewhere
10948  {
10950  {
10951  AddAura(GetMountBlockId(), this);
10952  SetMountBlockId(0);
10953  }
10954  }
10955 
10956  // update zone
10957  uint32 newzone, newarea;
10958  GetZoneAndAreaId(newzone, newarea);
10959  UpdateZone(newzone, newarea); // also call SendInitWorldStates();
10960 
10963 
10964  // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that must not be re-applied.
10966  {
10967  WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
10968  data2 << GetPackGUID();
10969  data2 << (uint32)2;
10970  SendMessageToSet(&data2, true);
10971  }
10972 
10973  GetAurasForTarget(this);
10974  SendEnchantmentDurations(); // must be after add to map
10975  SendItemDurations(); // must be after add to map
10977 
10978  // raid downscaling - send difficulty to player
10979  if (GetMap()->IsRaid())
10980  {
10981  if (GetMap()->GetDifficulty() != GetRaidDifficulty())
10982  {
10985  }
10986  }
10988  SendRaidDifficulty(GetGroup() != nullptr);
10989 }
10990 
10992 {
10994  return;
10995  if (Group* group = GetGroup())
10996  group->UpdatePlayerOutOfRange(this);
10997 
11000  if (Pet* pet = GetPet())
11001  pet->ResetAuraUpdateMaskForRaid();
11002 }
11003 
11005 {
11006  WorldPacket data(SMSG_TRANSFER_ABORTED, 4 + 2);
11007  data << uint32(mapid);
11008  data << uint8(reason); // transfer abort reason
11009  switch (reason)
11010  {
11014  // these are the ONLY cases that have an extra argument in the packet!!!
11015  data << uint8(arg);
11016  break;
11017  default:
11018  break;
11019  }
11020  GetSession()->SendPacket(&data);
11021 }
11022 
11023 void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap)
11024 {
11025  // pussywizard:
11026  InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(GetGUID(), mapid, difficulty);
11027  if (bind && bind->extended)
11028  {
11029  if (!onEnterMap) // extended id player shouldn't be warned about lock expiration
11030  return;
11031  time += (bind->save->GetExtendedResetTime() - bind->save->GetResetTime()); // add lockout period to the time left
11032  }
11033 
11034  // type of warning, based on the time remaining until reset
11035  uint32 type;
11036  if (time > 3600)
11037  type = RAID_INSTANCE_WELCOME;
11038  else if (time > 900)
11040  else if (time > 300)
11042  else
11044 
11045  WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4 + 4 + 4 + 4);
11046  data << uint32(type);
11047  data << uint32(mapid);
11048  data << uint32(difficulty); // difficulty
11049  data << uint32(time);
11050  if (type == RAID_INSTANCE_WELCOME)
11051  {
11052  data << uint8(bind && bind->perm); // is locked
11053  data << uint8(bind && bind->extended); // is extended, ignored if prev field is 0
11054  }
11055  GetSession()->SendPacket(&data);
11056 }
11057 
11059 {
11061  return;
11062 
11063  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
11064  {
11065  _Spell const& spellData = pItem->GetTemplate()->Spells[i];
11066 
11067  // no spell
11068  if (!spellData.SpellId)
11069  continue;
11070 
11071  // xinef: apply hidden cooldown for procs
11072  if (spellData.SpellTrigger == ITEM_SPELLTRIGGER_ON_EQUIP)
11073  {
11074  // xinef: uint32(-1) special marker for proc cooldowns
11075  AddSpellCooldown(spellData.SpellId, uint32(-1), 30 * IN_MILLISECONDS);
11076  continue;
11077  }
11078 
11079  // wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown)
11080  if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
11081  continue;
11082 
11083  // xinef: dont apply equip cooldown if spell on item has insignificant cooldown
11084  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellData.SpellId);
11085  if (spellData.SpellCooldown <= 3000 && spellData.SpellCategoryCooldown <= 3000 && (!spellInfo || (spellInfo->RecoveryTime <= 3000 && spellInfo->CategoryRecoveryTime <= 3000)))
11086  continue;
11087 
11088  // Don't replace longer cooldowns by equip cooldown if we have any.
11089  SpellCooldowns::iterator itr = m_spellCooldowns.find(spellData.SpellId);
11090  if (itr != m_spellCooldowns.end() && itr->second.itemid == pItem->GetEntry() && itr->second.end > World::GetGameTimeMS() + 30 * IN_MILLISECONDS)
11091  continue;
11092 
11093  // xinef: dont apply eqiup cooldown for spells with this attribute
11094  if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR0_NOT_IN_COMBAT_ONLY_PEACEFUL))
11095  continue;
11096 
11097  AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), 30 * IN_MILLISECONDS, true, true);
11098 
11099  WorldPacket data(SMSG_ITEM_COOLDOWN, 12);
11100  data << pItem->GetGUID();
11101  data << uint32(spellData.SpellId);
11102  GetSession()->SendPacket(&data);
11103  }
11104 }
11105 
11107 {
11108  // not need after this call
11111 
11112  // make full copy of map (spells removed and marked as deleted at another spell remove
11113  // and we can't use original map for safe iterative with visit each spell at loop end
11114  PlayerSpellMap spellMap = GetSpellMap();
11115 
11116  for (PlayerSpellMap::const_iterator iter = spellMap.begin(); iter != spellMap.end(); ++iter)
11117  removeSpell(iter->first, SPEC_MASK_ALL, false);
11118 
11122 }
11123 
11125 {
11126  if (!sWorld->getBoolConfig(CONFIG_START_ALL_SPELLS))
11127  {
11128  return;
11129  }
11130 
11131  // learn default race/class spells
11132  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
11133  ASSERT(info);
11134  for (PlayerCreateInfoSpells::const_iterator itr = info->customSpells.begin(); itr != info->customSpells.end(); ++itr)
11135  {
11136  uint32 tspell = *itr;
11137  LOG_DEBUG("entities.player.loading", "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)",
11138  GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getRace()), tspell);
11139  if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
11140  {
11141  addSpell(tspell, SPEC_MASK_ALL, true);
11142  }
11143  else // but send in normal spell in game learn case
11144  {
11145  learnSpell(tspell);
11146  }
11147  }
11148 }
11149 
11151 {
11152  // learn default race/class skills
11153  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
11154  for (PlayerCreateInfoSkills::const_iterator itr = info->skills.begin(); itr != info->skills.end(); ++itr)
11155  {
11156  uint32 skillId = itr->SkillId;
11157  if (HasSkill(skillId))
11158  continue;
11159 
11160  LearnDefaultSkill(skillId, itr->Rank);
11161  }
11162 }
11163 
11165 {
11166  SkillRaceClassInfoEntry const* rcInfo = GetSkillRaceClassInfo(skillId, getRace(), getClass());
11167  if (!rcInfo)
11168  return;
11169 
11170  LOG_DEBUG("entities.player.loading", "PLAYER (Class: %u Race: %u): Adding initial skill, id = %u", uint32(getClass()), uint32(getRace()), skillId);
11171  switch (GetSkillRangeType(rcInfo))
11172  {
11173  case SKILL_RANGE_LANGUAGE:
11174  SetSkill(skillId, 0, 300, 300);
11175  break;
11176  case SKILL_RANGE_LEVEL:
11177  {
11178  uint16 skillValue = 1;
11179  uint16 maxValue = GetMaxSkillValueForLevel();
11180  if (sWorld->getBoolConfig(CONFIG_ALWAYS_MAXSKILL) && !IsProfessionOrRidingSkill(skillId))
11181  {
11182  skillValue = maxValue;
11183  }
11184  else if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
11185  {
11186  skillValue = maxValue;
11187  }
11188  else if (getClass() == CLASS_DEATH_KNIGHT)
11189  {
11190  skillValue = std::min(std::max<uint16>({ 1, uint16((getLevel() - 1) * 5) }), maxValue);
11191  }
11192  else if (skillId == SKILL_FIST_WEAPONS)
11193  {
11194  skillValue = std::max<uint16>(1, GetSkillValue(SKILL_UNARMED));
11195  }
11196  else if (skillId == SKILL_LOCKPICKING)
11197  {
11198  skillValue = std::max<uint16>(1, GetSkillValue(SKILL_LOCKPICKING));
11199  }
11200 
11201  SetSkill(skillId, 0, skillValue, maxValue);
11202  break;
11203  }
11204  case SKILL_RANGE_MONO:
11205  SetSkill(skillId, 0, 1, 1);
11206  break;
11207  case SKILL_RANGE_RANK:
11208  {
11209  if (!rank)
11210  {
11211  break;
11212  }
11213 
11214  SkillTiersEntry const* tier = sSkillTiersStore.LookupEntry(rcInfo->SkillTierID);
11215  uint16 maxValue = tier->Value[std::max<int32>(rank - 1, 0)];
11216  uint16 skillValue = 1;
11217  if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
11218  {
11219  skillValue = maxValue;
11220  }
11221  else if (getClass() == CLASS_DEATH_KNIGHT)
11222  {
11223  skillValue = std::min(std::max<uint16>({ uint16(1), uint16((getLevel() - 1) * 5) }), maxValue);
11224  }
11225 
11226  SetSkill(skillId, rank, skillValue, maxValue);
11227  break;
11228  }
11229  default:
11230  break;
11231  }
11232 }
11233 
11235 {
11236  // xinef: quest does not learn anything
11237  int32 spellId = quest->GetRewSpellCast();
11238  if (!spellId)
11239  return;
11240 
11241  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
11242  if (!spellInfo)
11243  return;
11244 
11245  // xinef: find effect with learn spell and check if we have this spell
11246  bool found = false;
11247  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
11248  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL && spellInfo->Effects[i].TriggerSpell && !HasSpell(spellInfo->Effects[i].TriggerSpell))
11249  {
11250  // pusywizard: don't re-add profession specialties!
11251  if (SpellInfo const* triggeredInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell))
11252  if (triggeredInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL)
11253  break; // pussywizard: break and not cast the spell (found is false)
11254 
11255  found = true;
11256  break;
11257  }
11258 
11259  // xinef: we know the spell, return
11260  if (!found)
11261  return;
11262 
11263  CastSpell(this, spellId, true);
11264 }
11265 
11267 {
11268  // learn spells received from quest completing
11269  for (RewardedQuestSet::const_iterator itr = m_RewardedQuests.begin(); itr != m_RewardedQuests.end(); ++itr)
11270  {
11271  Quest const* quest = sObjectMgr->GetQuestTemplate(*itr);
11272  if (!quest)
11273  continue;
11274 
11275  learnQuestRewardedSpells(quest);
11276  }
11277 }
11278 
11280 {
11281  uint32 raceMask = getRaceMask();
11282  uint32 classMask = getClassMask();
11283  for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
11284  {
11285  SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j);
11286  if (!pAbility || pAbility->SkillLine != skill_id)
11287  {
11288  continue;
11289  }
11290 
11291  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pAbility->Spell);
11292  if (!spellInfo)
11293  {
11294  continue;
11295  }
11296 
11298  {
11299  continue;
11300  }
11301 
11302  // Check race if set
11303  if (pAbility->RaceMask && !(pAbility->RaceMask & raceMask))
11304  {
11305  continue;
11306  }
11307 
11308  // Check class if set
11309  if (pAbility->ClassMask && !(pAbility->ClassMask & classMask))
11310  {
11311  continue;
11312  }
11313 
11314  // need unlearn spell
11315  if (skill_value < pAbility->MinSkillLineRank && pAbility->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE)
11316  {
11317  removeSpell(pAbility->Spell, GetActiveSpec(), true);
11318  }
11319  // need learn
11320  else
11321  {
11322  //used to avoid double Seal of Righteousness on paladins, it's the only player spell which has both spell and forward spell in auto learn
11324  {
11325  bool skipCurrent = false;
11326  auto bounds = sSpellMgr->GetSkillLineAbilityMapBounds(pAbility->SupercededBySpell);
11327  for (auto itr = bounds.first; itr != bounds.second; ++itr)
11328  {
11329  if (itr->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && skill_value >= itr->second->MinSkillLineRank)
11330  {
11331  skipCurrent = true;
11332  break;
11333  }
11334  }
11335  if (skipCurrent)
11336  {
11337  continue;
11338  }
11339  }
11340 
11341  if (!IsInWorld())
11342  {
11343  addSpell(pAbility->Spell, SPEC_MASK_ALL, true, true);
11344  }
11345  else
11346  {
11347  learnSpell(pAbility->Spell, true, true);
11348  }
11349  }
11350  }
11351 }
11352 
11353 void Player::GetAurasForTarget(Unit* target) // pussywizard: contact before changing ANYTHING!
11354 {
11355  if (!target/* || target->GetVisibleAuras()->empty()*/) // speedup things
11356  return;
11357 
11361  if (target->HasAuraType(SPELL_AURA_FEATHER_FALL))
11362  target->SendMovementFeatherFall(this);
11363 
11364  if (target->HasAuraType(SPELL_AURA_WATER_WALK))
11365  target->SendMovementWaterWalking(this);
11366 
11367  if (target->HasAuraType(SPELL_AURA_HOVER))
11368  target->SendMovementHover(this);
11369 
11371  data<< target->GetPackGUID();
11372 
11373  Unit::VisibleAuraMap const* visibleAuras = target->GetVisibleAuras();
11374  for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
11375  {
11376  AuraApplication* auraApp = itr->second;
11377  auraApp->BuildUpdatePacket(data, false);
11378  }
11379 
11380  GetSession()->SendPacket(&data);
11381 }
11382 
11384 {
11385  if (Quest const* qQuest = sObjectMgr->GetQuestTemplate(quest_id))
11386  {
11387  if (!qQuest->IsDFQuest())
11388  {
11389  for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
11390  {
11391  if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx))
11392  {
11393  SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id);
11394  m_lastDailyQuestTime = time(nullptr); // last daily quest time
11395  m_DailyQuestChanged = true;
11396  break;
11397  }
11398  }
11399  }
11400  else
11401  {
11402  m_DFQuests.insert(quest_id);
11403  m_lastDailyQuestTime = time(nullptr);
11404  m_DailyQuestChanged = true;
11405  }
11406  }
11407 }
11408 
11410 {
11411  if (sObjectMgr->GetQuestTemplate(quest_id))
11412  {
11413  for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
11414  {
11415  if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx) == quest_id)
11416  {
11417  return true;
11418  }
11419  }
11420  }
11421 
11422  return false;
11423 }
11424 
11426 {
11427  m_weeklyquests.insert(quest_id);
11428  m_WeeklyQuestChanged = true;
11429 }
11430 
11432 {
11433  Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
11434  if (!quest)
11435  return;
11436 
11437  m_seasonalquests[quest->GetEventIdForQuest()].insert(quest_id);
11438  m_SeasonalQuestChanged = true;
11439 }
11440 
11442 {
11443  m_monthlyquests.insert(quest_id);
11444  m_MonthlyQuestChanged = true;
11445 }
11446 
11448 {
11449  for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
11450  SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, 0);
11451 
11452  m_DFQuests.clear(); // Dungeon Finder Quests.
11453 
11454  // DB data deleted in caller
11455  m_DailyQuestChanged = false;
11457 }
11458 
11460 {
11461  if (m_weeklyquests.empty())
11462  return;
11463 
11464  m_weeklyquests.clear();
11465  // DB data deleted in caller
11466  m_WeeklyQuestChanged = false;
11467 }
11468 
11470 {
11471  if (m_seasonalquests.empty() || m_seasonalquests[event_id].empty())
11472  return;
11473 
11474  m_seasonalquests.erase(event_id);
11475  // DB data deleted in caller
11476  m_SeasonalQuestChanged = false;
11477 }
11478 
11480 {
11481  if (m_monthlyquests.empty())
11482  return;
11483 
11484  m_monthlyquests.clear();
11485  // DB data deleted in caller
11486  m_MonthlyQuestChanged = false;
11487 }
11488 
11490 {
11491  if (GetBattlegroundId() == 0)
11492  return nullptr;
11493 
11494  Battleground* bg = sBattlegroundMgr->GetBattleground(GetBattlegroundId());
11495  return (create || (bg && bg->FindBgMap()) ? bg : nullptr);
11496 }
11497 
11498 bool Player::InArena() const
11499 {
11500  Battleground* bg = GetBattleground();
11501  if (!bg || !bg->isArena())
11502  return false;
11503 
11504  return true;
11505 }
11506 
11507 void Player::SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
11508 {
11509  // if leaving current bg (and was invited) - decrease invited count for current one
11511  if (Battleground* bg = sBattlegroundMgr->GetBattleground(m_bgData.bgInstanceID))
11512  bg->DecreaseInvitedCount(m_bgData.bgTeamId);
11513 
11514  // if entering new bg (and is invited) - increase invited count for new one
11515  if (id && invited)
11516  if (Battleground* bg = sBattlegroundMgr->GetBattleground(id))
11517  bg->IncreaseInvitedCount(teamId);
11518 
11519  m_bgData.bgInstanceID = id;
11520  m_bgData.bgTypeID = bgTypeId;
11521  m_bgData.bgQueueSlot = queueSlot;
11522  m_bgData.isInvited = invited;
11523  m_bgData.bgIsRandom = isRandom;
11524 
11525  m_bgData.bgTeamId = teamId;
11526  SetByteValue(PLAYER_BYTES_3, 3, uint8(teamId == TEAM_ALLIANCE ? 1 : 0));
11527 }
11528 
11530 {
11531  // get a template bg instead of running one
11532  Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
11533  if (!bgt)
11534  return false;
11535 
11536  // limit check leel to dbc compatible level range
11537  uint32 level = getLevel();
11538  if (level > DEFAULT_MAX_LEVEL)
11539  level = DEFAULT_MAX_LEVEL;
11540 
11541  if (level < bgt->GetMinLevel() || level > bgt->GetMaxLevel())
11542  return false;
11543 
11544  return true;
11545 }
11546 
11547 float Player::GetReputationPriceDiscount(Creature const* creature) const
11548 {
11549  FactionTemplateEntry const* vendor_faction = creature->GetFactionTemplateEntry();
11550  if (!vendor_faction || !vendor_faction->faction)
11551  return 1.0f;
11552 
11553  ReputationRank rank = GetReputationRank(vendor_faction->faction);
11554  if (rank <= REP_NEUTRAL)
11555  return 1.0f;
11556 
11557  return 1.0f - 0.05f * (rank - REP_NEUTRAL);
11558 }
11559 
11561 {
11562  uint32 racemask = getRaceMask();
11563  uint32 classmask = getClassMask();
11564 
11565  SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spell_id);
11566  if (bounds.first == bounds.second)
11567  return true;
11568 
11569  for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
11570  {
11571  // skip wrong race skills
11572  if (_spell_idx->second->RaceMask && (_spell_idx->second->RaceMask & racemask) == 0)
11573  continue;
11574 
11575  // skip wrong class skills
11576  if (_spell_idx->second->ClassMask && (_spell_idx->second->ClassMask & classmask) == 0)
11577  continue;
11578 
11579  return true;
11580  }
11581 
11582  return false;
11583 }
11584 
11586 {
11587  for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
11588  {
11589  uint32 questid = GetQuestSlotQuestId(i);
11590  if (questid == 0)
11591  continue;
11592 
11593  QuestStatusMap::const_iterator qs_itr = m_QuestStatus.find(questid);
11594  if (qs_itr == m_QuestStatus.end())
11595  continue;
11596 
11597  QuestStatusData const& qs = qs_itr->second;
11598 
11599  if (qs.Status == QUEST_STATUS_INCOMPLETE)
11600  {
11601  Quest const* qinfo = sObjectMgr->GetQuestTemplate(questid);
11602  if (!qinfo)
11603  continue;
11604 
11605  if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid(GetMap()->GetDifficulty()))
11606  continue;
11607 
11608  for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
11609  {
11610  if (qinfo->RequiredNpcOrGo[j] >= 0) //skip non GO case
11611  continue;
11612 
11613  if ((-1)*GOId == qinfo->RequiredNpcOrGo[j] && qs.CreatureOrGOCount[j] < qinfo->RequiredNpcOrGoCount[j])
11614  return true;
11615  }
11616  }
11617  }
11618  return false;
11619 }
11620 
11621 void Player::SummonIfPossible(bool agree, ObjectGuid summoner_guid)
11622 {
11623  if (!agree)
11624  {
11625  m_summon_expire = 0;
11626  return;
11627  }
11628 
11629  // expire and auto declined
11630  if (m_summon_expire < time(nullptr))
11631  return;
11632 
11633  // drop flag at summon
11634  // this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag
11635  if (Battleground* bg = GetBattleground())
11636  bg->EventPlayerDroppedFlag(this);
11637 
11638  m_summon_expire = 0;
11639 
11641 
11643 }
11644 
11646 {
11647  for (ItemDurationList::iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr)
11648  {
11649  if (*itr == item)
11650  {
11651  m_itemDuration.erase(itr);
11652  break;
11653  }
11654  }
11655 }
11656 
11658 {
11660  {
11661  m_itemDuration.push_back(item);
11662  item->SendTimeUpdate(this);
11663  }
11664 }
11665 
11666 void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/)
11667 {
11669  if (!offItem)
11670  {
11671  UpdateTitansGrip();
11672  return;
11673  }
11674 
11675  // unequip offhand weapon if player doesn't have dual wield anymore
11677  force = true;
11678 
11679  // need unequip offhand for 2h-weapon without TitanGrip (in any from hands)
11680  if (!force && (CanTitanGrip() || (offItem->GetTemplate()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed())))
11681  {
11682  UpdateTitansGrip();
11683  return;
11684  }
11685 
11686  ItemPosCountVec off_dest;
11687  uint8 off_msg = CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false);
11688  if (off_msg == EQUIP_ERR_OK)
11689  {
11691  StoreItem(off_dest, offItem, true);
11692  }
11693  else
11694  {
11696  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
11697  offItem->DeleteFromInventoryDB(trans); // deletes item from character's inventory
11698  offItem->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
11699 
11700  std::string subject = GetSession()->GetAcoreString(LANG_NOT_EQUIPPED_ITEM);
11701  MailDraft(subject, "There were problems with equipping one or several items").AddItem(offItem).SendMailTo(trans, this, MailSender(this, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_COPIED);
11702 
11703  CharacterDatabase.CommitTransaction(trans);
11704  }
11705  UpdateTitansGrip();
11706 }
11707 
11709 {
11710  return sOutdoorPvPMgr->GetOutdoorPvPToZoneId(GetZoneId());
11711 }
11712 
11713 bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem) const
11714 {
11715  if (spellInfo->EquippedItemClass < 0)
11716  return true;
11717 
11718  // scan other equipped items for same requirements (mostly 2 daggers/etc)
11719  // for optimize check 2 used cases only
11720  switch (spellInfo->EquippedItemClass)
11721  {
11722  case ITEM_CLASS_WEAPON:
11723  {
11726  if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo))
11727  return true;
11728  break;
11729  }
11730  case ITEM_CLASS_ARMOR:
11731  {
11732  // tabard not have dependent spells
11735  if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo))
11736  return true;
11737 
11738  // shields can be equipped to offhand slot
11740  if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo))
11741  return true;
11742 
11743  // ranged slot can have some armor subclasses
11745  if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo))
11746  return true;
11747 
11748  break;
11749  }
11750  default:
11751  LOG_ERROR("entities.player", "HasItemFitToSpellRequirements: Not handled spell requirement for item class %u", spellInfo->EquippedItemClass);
11752  break;
11753  }
11754 
11755  return false;
11756 }
11757 
11758 bool Player::CanNoReagentCast(SpellInfo const* spellInfo) const
11759 {
11760  // don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_COST_WITH_AURA
11762  return true;
11763 
11764  // Check no reagent use mask
11765  flag96 noReagentMask;
11766  noReagentMask[0] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1);
11767  noReagentMask[1] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 1);
11768  noReagentMask[2] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2);
11769  if (spellInfo->SpellFamilyFlags & noReagentMask)
11770  return true;
11771 
11772  return false;
11773 }
11774 
11776 {
11777  for (AuraMap::iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end();)
11778  {
11779  Aura* aura = itr->second;
11780 
11781  // skip passive (passive item dependent spells work in another way) and not self applied auras
11782  SpellInfo const* spellInfo = aura->GetSpellInfo();
11783  if (aura->IsPassive() || aura->GetCasterGUID() != GetGUID())
11784  {
11785  ++itr;
11786  continue;
11787  }
11788 
11789  // skip if not item dependent or have alternative item
11790  if (HasItemFitToSpellRequirements(spellInfo, pItem))
11791  {
11792  ++itr;
11793  continue;
11794  }
11795 
11796  // no alt item, remove aura, restart check
11797  RemoveOwnedAura(itr);
11798  }
11799 
11800  // currently casted spells can be dependent from item
11801  for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
11802  if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i)))
11803  if (spell->getState() != SPELL_STATE_DELAYED && !HasItemFitToSpellRequirements(spell->m_spellInfo, pItem))
11805 }
11806 
11808 {
11809  // search priceless resurrection possibilities
11810  uint32 prio = 0;
11811  uint32 spell_id = 0;
11813  for (AuraEffectList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
11814  {
11815  // Soulstone Resurrection // prio: 3 (max, non death persistent)
11816  if (prio < 2 && (*itr)->GetSpellInfo()->SpellVisual[0] == 99 && (*itr)->GetSpellInfo()->SpellIconID == 92)
11817  {
11818  switch ((*itr)->GetId())
11819  {
11820  case 20707:
11821  spell_id = 3026;
11822  break; // rank 1
11823  case 20762:
11824  spell_id = 20758;
11825  break; // rank 2
11826  case 20763:
11827  spell_id = 20759;
11828  break; // rank 3
11829  case 20764:
11830  spell_id = 20760;
11831  break; // rank 4
11832  case 20765:
11833  spell_id = 20761;
11834  break; // rank 5
11835  case 27239:
11836  spell_id = 27240;
11837  break; // rank 6
11838  case 47883:
11839  spell_id = 47882;
11840  break; // rank 7
11841  default:
11842  LOG_ERROR("entities.player", "Unhandled spell %u: S.Resurrection", (*itr)->GetId());
11843  continue;
11844  }
11845 
11846  prio = 3;
11847  }
11848  // Twisting Nether // prio: 2 (max)
11849  else if ((*itr)->GetId() == 23701 && roll_chance_i(10))
11850  {
11851  prio = 2;
11852  spell_id = 23700;
11853  }
11854  }
11855 
11856  // Reincarnation (passive spell) // prio: 1 // Glyph of Renewed Life
11857  if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasAura(58059) || HasItemCount(17030)))
11858  spell_id = 21169;
11859 
11860  return spell_id;
11861 }
11862 
11863 // Used in triggers for check "Only to targets that grant experience or honor" req
11864 bool Player::isHonorOrXPTarget(Unit* victim) const
11865 {
11866  uint8 v_level = victim->getLevel();
11868 
11869  // Victim level less gray level
11870  if (v_level <= k_grey)
11871  return false;
11872 
11873  if (victim->GetTypeId() == TYPEID_UNIT)
11874  {
11875  if (victim->IsTotem() ||
11876  victim->IsPet() ||
11878  return false;
11879  }
11880  return true;
11881 }
11882 
11884 {
11885  bool recruitAFriend = false;
11886  if (getLevel() <= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL) || !forXP)
11887  {
11888  if (Group* group = this->GetGroup())
11889  {
11890  for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
11891  {
11892  Player* player = itr->GetSource();
11893  if (!player || !player->IsInMap(this))
11894  continue;
11895 
11896  if (!player->IsAtRecruitAFriendDistance(this))
11897  continue; // member (alive or dead) or his corpse at req. distance
11898 
11899  if (forXP)
11900  {
11901  // level must be allowed to get RaF bonus
11902  if (player->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
11903  continue;
11904 
11905  // level difference must be small enough to get RaF bonus, UNLESS we are lower level
11906  if (player->getLevel() < getLevel())
11908  continue;
11909  }
11910 
11911  bool ARecruitedB = (player->GetSession()->GetRecruiterId() == GetSession()->GetAccountId());
11912  bool BRecruitedA = (GetSession()->GetRecruiterId() == player->GetSession()->GetAccountId());
11913  if (ARecruitedB || BRecruitedA)
11914  {
11915  recruitAFriend = true;
11916  break;
11917  }
11918  }
11919  }
11920  }
11921  return recruitAFriend;
11922 }
11923 
11924 void Player::RewardPlayerAndGroupAtKill(Unit* victim, bool isBattleGround)
11925 {
11926  KillRewarder(this, victim, isBattleGround).Reward();
11927 }
11928 
11929 void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource)
11930 {
11931  if (!pRewardSource)
11932  return;
11933 
11934  ObjectGuid creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : ObjectGuid::Empty;
11935 
11936  // prepare data for near group iteration
11937  if (Group* group = GetGroup())
11938  {
11939  for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
11940  {
11941  Player* player = itr->GetSource();
11942  if (!player)
11943  continue;
11944 
11945  if (!player->IsAtGroupRewardDistance(pRewardSource))
11946  continue; // member (alive or dead) or his corpse at req. distance
11947 
11948  // quest objectives updated only for alive group member or dead but with not released body
11949  if (player->IsAlive() || !player->GetCorpse())
11950  player->KilledMonsterCredit(creature_id, creature_guid);
11951  }
11952  }
11953  else // if (!group)
11954  KilledMonsterCredit(creature_id, creature_guid);
11955 }
11956 
11957 bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const
11958 {
11959  WorldObject const* player = GetCorpse();
11960  if (!player || IsAlive())
11961  {
11962  player = this;
11963  }
11964 
11965  if (!pRewardSource || !player->IsInMap(pRewardSource))
11966  {
11967  return false;
11968  }
11969 
11970  if (pRewardSource->GetMap()->IsDungeon())
11971  {
11972  return true;
11973  }
11974 
11975  return pRewardSource->GetDistance(player) <= sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE);
11976 }
11977 
11978 bool Player::IsAtLootRewardDistance(WorldObject const* pRewardSource) const
11979 {
11980  if (!IsAtGroupRewardDistance(pRewardSource))
11981  {
11982  return false;
11983  }
11984 
11985  if (HasPendingBind())
11986  {
11987  return false;
11988  }
11989 
11990  return pRewardSource->HasAllowedLooter(GetGUID());
11991 }
11992 
11994 {
11995  if (!pOther)
11996  return false;
11997  const WorldObject* player = GetCorpse();
11998  if (!player || IsAlive())
11999  player = this;
12000 
12001  if (player->GetMapId() != pOther->GetMapId() || player->GetInstanceId() != pOther->GetInstanceId())
12002  return false;
12003 
12004  return pOther->GetDistance(player) <= sWorld->getFloatConfig(CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE);
12005 }
12006 
12008 {
12009  Item* item = GetWeaponForAttack(attType, true);
12010 
12011  // unarmed only with base attack
12012  if (attType != BASE_ATTACK && !item)
12013  return 0;
12014 
12015  // weapon skill or (unarmed for base attack)
12016  uint32 skill = item ? item->GetSkill() : uint32(SKILL_UNARMED);
12017  return GetBaseSkillValue(skill);
12018 }
12019 
12021 {
12024 
12025  if (IsBeingTeleported())
12026  {
12028  return;
12029  }
12030 
12031  ResurrectPlayer(0.0f, false);
12032 
12035  else
12036  SetFullHealth();
12037 
12040  else
12042 
12043  SetPower(POWER_RAGE, 0);
12044 
12046 
12047  SpawnCorpseBones();
12048 }
12049 
12050 void Player::SetClientControl(Unit* target, bool allowMove, bool packetOnly /*= false*/)
12051 {
12052  WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size() + 1);
12053  data << target->GetPackGUID();
12054  data << uint8((allowMove && !target->HasUnitState(UNIT_STATE_FLEEING | UNIT_STATE_CONFUSED)) ? 1 : 0);
12055  GetSession()->SendPacket(&data);
12056 
12057  // We want to set the packet only
12058  if (packetOnly)
12059  return;
12060 
12061  if (this != target)
12062  SetViewpoint(target, allowMove);
12063 
12064  if (allowMove)
12065  SetMover(target);
12066 
12067  // Xinef: disable moving if target has disable move flag
12068  if (target->GetTypeId() != TYPEID_UNIT)
12069  return;
12070 
12071  if (allowMove && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
12072  {
12074  target->SetControlled(true, UNIT_STATE_ROOT);
12075  }
12076  else if (!allowMove && target->HasUnitState(UNIT_STATE_ROOT) && !target->HasUnitTypeMask(UNIT_MASK_ACCESSORY))
12077  {
12079  {
12080  // Xinef: restore original orientation, important for shooting vehicles!
12082  target->SetOrientation(pos.GetOrientation());
12083  target->SetFacingTo(pos.GetOrientation());
12084  target->DisableSpline();
12085  }
12086  else
12087  target->SetControlled(false, UNIT_STATE_ROOT);
12088  }
12089 }
12090 
12091 void Player::SetMover(Unit* target)
12092 {
12093  if (this != target && target->m_movedByPlayer && target->m_movedByPlayer != target && target->m_movedByPlayer != this)
12094  {
12095  LOG_INFO("misc", "Player::SetMover (A1) - %s, %u, %u, %u, %u, %u, %u, %u", GetGUID().ToString().c_str(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0);
12096  LOG_INFO("misc", "Player::SetMover (A2) - %s, %u, %u, %u, %u, %u, %u, %u", target->GetGUID().ToString().c_str(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0);
12097  LOG_INFO("misc", "Player::SetMover (A3) - %s, %u, %u, %u, %u, %u, %u, %u", target->m_movedByPlayer->GetGUID().ToString().c_str(), target->m_movedByPlayer->GetMapId(), target->m_movedByPlayer->GetInstanceId(), target->m_movedByPlayer->FindMap()->GetId(), target->m_movedByPlayer->IsInWorld() ? 1 : 0, target->m_movedByPlayer->IsDuringRemoveFromWorld() ? 1 : 0, target->m_movedByPlayer->ToPlayer()->IsBeingTeleported() ? 1 : 0, target->m_movedByPlayer->isBeingLoaded() ? 1 : 0);
12098  }
12099  if (this != target && (!target->IsInWorld() || target->IsDuringRemoveFromWorld() || GetMapId() != target->GetMapId() || GetInstanceId() != target->GetInstanceId()))
12100  {
12101  LOG_INFO("misc", "Player::SetMover (B1) - %s, %u, %u, %u, %u, %u, %u, %u", GetGUID().ToString().c_str(), GetMapId(), GetInstanceId(), FindMap()->GetId(), IsInWorld() ? 1 : 0, IsDuringRemoveFromWorld() ? 1 : 0, IsBeingTeleported() ? 1 : 0, isBeingLoaded() ? 1 : 0);
12102  LOG_INFO("misc", "Player::SetMover (B2) - %s, %u, %u, %u, %u, %u, %u, %u", target->GetGUID().ToString().c_str(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0);
12103  }
12104  m_mover->m_movedByPlayer = nullptr;
12105  m_mover = target;
12106  m_mover->m_movedByPlayer = this;
12107 }
12108 
12110 {
12111  if (pvp)
12112  {
12113  if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP))
12114  return copseReclaimDelay[0];
12115  }
12116  else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))
12117  return 0;
12118 
12119  time_t now = time(nullptr);
12120  // 0..2 full period
12121  // should be ceil(x)-1 but not floor(x)
12122  uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0;
12123  return copseReclaimDelay[count];
12124 }
12125 
12127 {
12128  Corpse* corpse = GetCorpse();
12129 
12130  if (load && !corpse)
12131  return -1;
12132 
12133  bool pvp = corpse ? corpse->GetType() == CORPSE_RESURRECTABLE_PVP : m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH;
12134 
12135  uint32 delay;
12136 
12137  if (load)
12138  {
12139  if (corpse->GetGhostTime() > m_deathExpireTime)
12140  return -1;
12141 
12142  uint64 count = 0;
12143 
12144  if ((pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP)) ||
12145  (!pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)))
12146  {
12147  count = (m_deathExpireTime - corpse->GetGhostTime()) / DEATH_EXPIRE_STEP;
12148 
12149  if (count >= MAX_DEATH_COUNT)
12150  count = MAX_DEATH_COUNT - 1;
12151  }
12152 
12153  time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count];
12154  time_t now = time(nullptr);
12155 
12156  if (now >= expected_time)
12157  return -1;
12158 
12159  delay = expected_time - now;
12160  }
12161  else
12162  delay = GetCorpseReclaimDelay(pvp);
12163 
12164  return delay * IN_MILLISECONDS;
12165 }
12166 
12168 {
12170  data << uint32(delay);
12171  GetSession()->SendPacket(&data);
12172 }
12173 
12175 {
12176  Group* group = GetGroup();
12177  if (!group)
12178  return nullptr;
12179 
12180  std::vector<Player*> nearMembers;
12181  nearMembers.reserve(group->GetMembersCount());
12182 
12183  for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
12184  {
12185  Player* Target = itr->GetSource();
12186 
12187  // IsHostileTo check duel and controlled by enemy
12188  if (Target && Target != this && IsWithinDistInMap(Target, radius) &&
12189  !Target->HasInvisibilityAura() && !IsHostileTo(Target))
12190  nearMembers.push_back(Target);
12191  }
12192 
12193  if (nearMembers.empty())
12194  return nullptr;
12195 
12196  uint32 randTarget = urand(0, nearMembers.size() - 1);
12197  return nearMembers[randTarget];
12198 }
12199 
12201 {
12202  Group const* grp = GetGroup();
12203  if (!grp)
12204  return ERR_NOT_IN_GROUP;
12205 
12206  if (grp->isLFGGroup(true))
12207  {
12208  ObjectGuid gguid = grp->GetGUID();
12209  if (!sLFGMgr->GetKicksLeft(gguid))
12210  return ERR_PARTY_LFG_BOOT_LIMIT;
12211 
12212  lfg::LfgState state = sLFGMgr->GetState(gguid);
12213  if (state == lfg::LFG_STATE_BOOT)
12215 
12218 
12219  if (state == lfg::LFG_STATE_FINISHED_DUNGEON)
12221 
12222  if (grp->isRollLootActive())
12224 
12225  // TODO: Should also be sent when anyone has recently left combat, with an aprox ~5 seconds timer.
12226  for (GroupReference const* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
12227  if (itr->GetSource() && itr->GetSource()->IsInMap(this) && itr->GetSource()->IsInCombat())
12229 
12230  if (Player* target = ObjectAccessor::FindConnectedPlayer(targetPlayerGUID))
12231  {
12232  if (Aura* dungeonCooldownAura = target->GetAura(lfg::LFG_SPELL_DUNGEON_COOLDOWN))
12233  {
12234  int32 elapsedTime = dungeonCooldownAura->GetMaxDuration() - dungeonCooldownAura->GetDuration();
12235  if (static_cast<int32>(sWorld->getIntConfig(CONFIG_LFG_KICK_PREVENTION_TIMER)) > elapsedTime)
12236  {
12238  }
12239  }
12240  }
12241 
12242  /* Missing support for these types
12243  return ERR_PARTY_LFG_BOOT_COOLDOWN_S;
12244  */
12245  }
12246  else
12247  {
12248  if (!grp->IsLeader(GetGUID()) && !grp->IsAssistant(GetGUID()))
12249  return ERR_NOT_LEADER;
12250 
12251  if (InBattleground())
12252  return ERR_INVITE_RESTRICTED;
12253  }
12254 
12255  return ERR_PARTY_RESULT_OK;
12256 }
12257 
12259 {
12260  return sLFGMgr->GetState(GetGUID()) != lfg::LFG_STATE_NONE;
12261 }
12262 
12264 {
12265  if (sLFGMgr->selectedRandomLfgDungeon(GetGUID()))
12266  {
12267  Map const* map = GetMap();
12268  return sLFGMgr->inLfgDungeonMap(GetGUID(), map->GetId(), map->GetDifficulty());
12269  }
12270 
12271  return false;
12272 }
12273 
12275 {
12276  //we must move references from m_group to m_originalGroup
12277  if (GetGroup() && (GetGroup()->isBGGroup() || GetGroup()->isBFGroup()))
12278  {
12279  LOG_INFO("misc", "Player::SetBattlegroundOrBattlefieldRaid - current group is %s group!", (GetGroup()->isBGGroup() ? "BG" : "BF"));
12280  //ABORT(); // pussywizard: origanal group can never be bf/bg group
12281  }
12282 
12284 
12285  m_group.unlink();
12286  m_group.link(group, this);
12287  m_group.setSubGroup((uint8)subgroup);
12288 }
12289 
12291 {
12292  //remove existing reference
12293  m_group.unlink();
12294  if (Group* group = GetOriginalGroup())
12295  {
12296  m_group.link(group, this);
12298  }
12299  SetOriginalGroup(nullptr);
12300 }
12301 
12302 void Player::SetOriginalGroup(Group* group, int8 subgroup)
12303 {
12304  if (group == nullptr)
12306  else
12307  {
12308  // never use SetOriginalGroup without a subgroup unless you specify nullptr for group
12309  ASSERT(subgroup >= 0);
12310  m_originalGroup.link(group, this);
12311  m_originalGroup.setSubGroup((uint8)subgroup);
12312  }
12313 }
12314 
12315 void Player::SetCanParry(bool value)
12316 {
12317  if (m_canParry == value)
12318  return;
12319 
12320  m_canParry = value;
12322 }
12323 
12324 void Player::SetCanBlock(bool value)
12325 {
12326  if (m_canBlock == value)
12327  return;
12328 
12329  m_canBlock = value;
12331 }
12332 
12333 void Player::SetCanTitanGrip(bool value)
12334 {
12335  m_canTitanGrip = value;
12336 }
12337 
12339 {
12340  for (ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr)
12341  if (itr->pos == pos)
12342  return true;
12343  return false;
12344 }
12345 
12347 {
12348  if (WorldObject* target = GetViewpoint())
12349  {
12350  if (target->isType(TYPEMASK_UNIT))
12351  {
12352  ((Unit*)target)->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, GetGUID());
12353  ((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, GetGUID());
12354  ((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS_PET, GetGUID());
12355  }
12356  }
12357 }
12358 
12360 {
12361  if (apply)
12362  {
12363  // target must be in world
12364  if (!target->IsInWorld())
12365  return;
12366 
12367  if (!IsInWorld() || IsDuringRemoveFromWorld())
12368  return;
12369 
12370  LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName().c_str(), target->GetEntry(), target->GetTypeId());
12371 
12372  if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID()))
12373  {
12374  LOG_FATAL("entities.player", "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName().c_str());
12375  return;
12376  }
12377 
12378  // farsight dynobj or puppet may be very far away
12379  UpdateVisibilityOf(target);
12380 
12381  if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
12382  ((Unit*)target)->AddPlayerToVision(this);
12383  }
12384  else
12385  {
12386  //must immediately set seer back otherwise may crash
12387  m_seer = this;
12388 
12389  LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s remove seer", GetName().c_str());
12390 
12391  if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
12392  ((Unit*)target)->RemovePlayerFromVision(this);
12393 
12394  if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID()))
12395  {
12396  LOG_FATAL("entities.player", "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName().c_str());
12397  return;
12398  }
12399 
12400  //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
12401  //GetSession()->SendPacket(&data);
12402  }
12403 }
12404 
12406 {
12409  return nullptr;
12410 }
12411 
12413 {
12414  // It is possible to call this method will a nullptr pointer, only skipping faction check.
12415  if (gameobject)
12416  {
12417  FactionTemplateEntry const* playerFaction = GetFactionTemplateEntry();
12418  FactionTemplateEntry const* faction = sFactionTemplateStore.LookupEntry(gameobject->GetUInt32Value(GAMEOBJECT_FACTION));
12419 
12420  if (playerFaction && faction && !playerFaction->IsFriendlyTo(*faction))
12421  return false;
12422  }
12423 
12424  // BUG: sometimes when player clicks on flag in AB - client won't send gameobject_use, only gameobject_report_use packet
12425  // Note: Mount, stealth and invisibility will be removed when used
12426  return (!isTotalImmune() && // Damage immune
12427  !HasAura(SPELL_RECENTLY_DROPPED_FLAG) && // Still has recently held flag debuff
12428  IsAlive()); // Alive
12429 }
12430 
12432 {
12433  return (!HasStealthAura() && // not stealthed
12434  !HasInvisibilityAura() && // not invisible
12435  IsAlive() // live player
12436  );
12437 }
12438 
12439 uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin)
12440 {
12441  uint8 level = getLevel();
12442 
12443  if (level > GT_MAX_LEVEL)
12444  level = GT_MAX_LEVEL; // max level in this dbc
12445 
12446  uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
12447  uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
12448  uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
12449  uint8 skincolor = GetByteValue(PLAYER_BYTES, 0);
12450 
12451  if ((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && (!newSkin || (newSkin->hair_id == skincolor)))
12452  return 0;
12453 
12454  GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1);
12455 
12456  if (!bsc) // shouldn't happen
12457  return 0xFFFFFFFF;
12458 
12459  float cost = 0;
12460 
12461  if (hairstyle != newhairstyle)
12462  cost += bsc->cost; // full price
12463 
12464  if ((haircolor != newhaircolor) && (hairstyle == newhairstyle))
12465  cost += bsc->cost * 0.5f; // +1/2 of price
12466 
12467  if (facialhair != newfacialhair)
12468  cost += bsc->cost * 0.75f; // +3/4 of price
12469 
12470  if (newSkin && skincolor != newSkin->hair_id)
12471  cost += bsc->cost * 0.75f; // +5/6 of price
12472 
12473  return uint32(cost);
12474 }
12475 
12477 {
12478  for (uint32 i = 0; i < sGlyphSlotStore.GetNumRows(); ++i)
12479  if (GlyphSlotEntry const* gs = sGlyphSlotStore.LookupEntry(i))
12480  if (gs->Order)
12481  SetGlyphSlot(gs->Order - 1, gs->Id);
12482 
12483  uint8 level = getLevel();
12484  uint32 value = 0;
12485 
12486  // 0x3F = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 for 80 level
12487  if (level >= 15)
12488  value |= (0x01 | 0x02);
12489  if (level >= 30)
12490  value |= 0x08;
12491  if (level >= 50)
12492  value |= 0x04;
12493  if (level >= 70)
12494  value |= 0x10;
12495  if (level >= 80)
12496  value |= 0x20;
12497 
12499 }
12500 
12502 {
12504 
12505  uint32 immuneMask = 0;
12506  for (AuraEffectList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr)
12507  {
12508  immuneMask |= (*itr)->GetMiscValue();
12509  if (immuneMask & SPELL_SCHOOL_MASK_ALL) // total immunity
12510  return true;
12511  }
12512  return false;
12513 }
12514 
12515 bool Player::HasTitle(uint32 bitIndex) const
12516 {
12517  if (bitIndex > MAX_TITLE_INDEX)
12518  return false;
12519 
12520  uint32 fieldIndexOffset = bitIndex / 32;
12521  uint32 flag = 1 << (bitIndex % 32);
12522  return HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
12523 }
12524 
12525 void Player::SetTitle(CharTitlesEntry const* title, bool lost)
12526 {
12527  uint32 fieldIndexOffset = title->bit_index / 32;
12528  uint32 flag = 1 << (title->bit_index % 32);
12529 
12530  if (lost)
12531  {
12532  if (!HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
12533  return;
12534 
12535  // Clear the current title if it is the one being removed.
12537  {
12538  SetCurrentTitle(nullptr, true);
12539  }
12540 
12541  RemoveFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
12542  }
12543  else
12544  {
12545  if (HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
12546  return;
12547 
12548  SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
12549  }
12550 
12551  WorldPacket data(SMSG_TITLE_EARNED, 4 + 4);
12552  data << uint32(title->bit_index);
12553  data << uint32(lost ? 0 : 1); // 1 - earned, 0 - lost
12554  GetSession()->SendPacket(&data);
12555 }
12556 
12558 {
12559  uint8 rune = GetBaseRune(index);
12560  uint32 cooldown = RUNE_BASE_COOLDOWN;
12561  if (!skipGrace)
12562  cooldown -= GetGracePeriod(index) < 250 ? 0 : GetGracePeriod(index) - 250; // xinef: reduce by grace period, treat first 250ms as instant use of rune
12563 
12565  for (AuraEffectList::const_iterator i = regenAura.begin(); i != regenAura.end(); ++i)
12566  {
12567  if ((*i)->GetMiscValue() == POWER_RUNE && (*i)->GetMiscValueB() == rune)
12568  cooldown = cooldown * (100 - (*i)->GetAmount()) / 100;
12569  }
12570 
12571  return cooldown;
12572 }
12573 
12575 {
12576  for (uint8 i = 0; i < MAX_RUNES; ++i)
12577  {
12578  if (m_runes->runes[i].ConvertAura == aura)
12579  {
12580  ConvertRune(i, GetBaseRune(i));
12581  SetRuneConvertAura(i, nullptr);
12582  }
12583  }
12584 }
12585 
12587 {
12588  AuraEffect const* aura = m_runes->runes[index].ConvertAura;
12589  // If rune was converted by a non-pasive aura that still active we should keep it converted
12590  if (aura && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
12591  return;
12592  ConvertRune(index, GetBaseRune(index));
12593  SetRuneConvertAura(index, nullptr);
12594  // Don't drop passive talents providing rune convertion
12595  if (!aura || aura->GetAuraType() != SPELL_AURA_CONVERT_RUNE)
12596  return;
12597  for (uint8 i = 0; i < MAX_RUNES; ++i)
12598  {
12599  if (aura == m_runes->runes[i].ConvertAura)
12600  return;
12601  }
12602  aura->GetBase()->Remove();
12603 }
12604 
12605 void Player::ConvertRune(uint8 index, RuneType newType)
12606 {
12607  SetCurrentRune(index, newType);
12608 
12609  WorldPacket data(SMSG_CONVERT_RUNE, 2);
12610  data << uint8(index);
12611  data << uint8(newType);
12612  GetSession()->SendPacket(&data);
12613 }
12614 
12616 {
12617  WorldPacket data(SMSG_RESYNC_RUNES, 4 + count * 2);
12618  data << uint32(count);
12619  for (uint32 i = 0; i < count; ++i)
12620  {
12621  data << uint8(GetCurrentRune(i)); // rune type
12622  data << uint8(255 - (GetRuneCooldown(i) * 51)); // passed cooldown time (0-255)
12623  }
12624  GetSession()->SendPacket(&data);
12625 }
12626 
12628 {
12630  data << uint32(1 << index); // mask (0x00-0x3F probably)
12631  GetSession()->SendPacket(&data);
12632 }
12633 
12635 {
12636  /*0*/ RUNE_BLOOD,
12637  /*1*/ RUNE_BLOOD,
12638  /*2*/ RUNE_UNHOLY,
12639  /*3*/ RUNE_UNHOLY,
12640  /*4*/ RUNE_FROST,
12641  /*5*/ RUNE_FROST
12642 };
12643 
12645 {
12646  if (getClass() != CLASS_DEATH_KNIGHT)
12647  return;
12648 
12649  m_runes = new Runes;
12650 
12651  m_runes->runeState = 0;
12653 
12654  for (uint8 i = 0; i < MAX_RUNES; ++i)
12655  {
12656  SetBaseRune(i, runeSlotTypes[i]); // init base types
12657  SetCurrentRune(i, runeSlotTypes[i]); // init current types
12658  SetRuneCooldown(i, 0); // reset cooldowns
12659  SetGracePeriod(i, 0); // xinef: reset grace period
12660  SetRuneConvertAura(i, nullptr);
12661  m_runes->SetRuneState(i);
12662  }
12663 
12664  for (uint8 i = 0; i < NUM_RUNE_TYPES; ++i)
12666 }
12667 
12669 {
12670  for (uint8 i = 0; i < MAX_RUNES; ++i)
12671  if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0)
12672  return false;
12673 
12674  return true;
12675 }
12676 
12677 void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast)
12678 {
12679  Loot loot;
12680  loot.FillLoot (loot_id, store, this, true);
12681 
12682  uint32 max_slot = loot.GetMaxSlotInLootFor(this);
12683  for (uint32 i = 0; i < max_slot; ++i)
12684  {
12685  LootItem* lootItem = loot.LootItemInSlot(i, this);
12686 
12687  ItemPosCountVec dest;
12688  InventoryResult msg = CanStoreNewItem(bag, slot, dest, lootItem->itemid, lootItem->count);
12689  if (msg != EQUIP_ERR_OK && slot != NULL_SLOT)
12690  msg = CanStoreNewItem(bag, NULL_SLOT, dest, lootItem->itemid, lootItem->count);
12691  if (msg != EQUIP_ERR_OK && bag != NULL_BAG)
12692  msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, lootItem->itemid, lootItem->count);
12693  if (msg != EQUIP_ERR_OK)
12694  {
12695  SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
12696  continue;
12697  }
12698 
12699  Item* pItem = StoreNewItem(dest, lootItem->itemid, true, lootItem->randomPropertyId);
12700  SendNewItem(pItem, lootItem->count, false, false, broadcast);
12701  }
12702 }
12703 
12704 void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
12705 {
12706  QuestItem* qitem = nullptr;
12707  QuestItem* ffaitem = nullptr;
12708  QuestItem* conditem = nullptr;
12709 
12710  LootItem* item = loot->LootItemInSlot(lootSlot, this, &qitem, &ffaitem, &conditem);
12711 
12712  if (!item || item->is_looted)
12713  {
12714  SendEquipError(EQUIP_ERR_ALREADY_LOOTED, nullptr, nullptr);
12715  return;
12716  }
12717 
12718  // Xinef: exploit protection, dont allow to loot normal items if player is not master loot and not below loot threshold
12719  // Xinef: only quest, ffa and conditioned items
12720  if (!item->is_underthreshold && loot->roundRobinPlayer && !GetLootGUID().IsItem() && GetGroup() && GetGroup()->GetLootMethod() == MASTER_LOOT && GetGUID() != GetGroup()->GetMasterLooterGuid())
12721  if (qitem == nullptr && ffaitem == nullptr && conditem == nullptr)
12722  {
12724  return;
12725  }
12726 
12727  if (!item->AllowedForPlayer(this))
12728  {
12730  return;
12731  }
12732 
12733  // questitems use the blocked field for other purposes
12734  if (!qitem && item->is_blocked)
12735  {
12737  return;
12738  }
12739 
12740  // xinef: dont allow protected item to be looted by someone else
12741  if (item->rollWinnerGUID && item->rollWinnerGUID != GetGUID())
12742  {
12744  return;
12745  }
12746 
12747  ItemPosCountVec dest;
12748  InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count);
12749  if (msg == EQUIP_ERR_OK)
12750  {
12751  AllowedLooterSet looters = item->GetAllowedLooters();
12752  Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, looters);
12753 
12754  if (qitem)
12755  {
12756  qitem->is_looted = true;
12757  //freeforall is 1 if everyone's supposed to get the quest item.
12758  if (item->freeforall || loot->GetPlayerQuestItems().size() == 1)
12759  SendNotifyLootItemRemoved(lootSlot);
12760  else
12761  loot->NotifyQuestItemRemoved(qitem->index);
12762  }
12763  else
12764  {
12765  if (ffaitem)
12766  {
12767  //freeforall case, notify only one player of the removal
12768  ffaitem->is_looted = true;
12769  SendNotifyLootItemRemoved(lootSlot);
12770  }
12771  else
12772  {
12773  //not freeforall, notify everyone
12774  if (conditem)
12775  conditem->is_looted = true;
12776  loot->NotifyItemRemoved(lootSlot);
12777  }
12778  }
12779 
12780  //if only one person is supposed to loot the item, then set it to looted
12781  if (!item->freeforall)
12782  item->is_looted = true;
12783 
12784  --loot->unlootedCount;
12785 
12786  SendNewItem(newitem, uint32(item->count), false, false, true);
12787  UpdateLootAchievements(item, loot);
12788 
12789  // LootItem is being removed (looted) from the container, delete it from the DB.
12790  if (loot->containerGUID)
12791  sLootItemStorage->RemoveStoredLootItem(loot->containerGUID, item->itemid, item->count, loot, item->itemIndex);
12792 
12793 #ifdef ELUNA
12794  sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID());
12795 #endif
12796  sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
12797  }
12798  else
12799  SendEquipError(msg, nullptr, nullptr, item->itemid);
12800 }
12801 
12803 {
12804  uint32 base_talent = getLevel() < 10 ? 0 : getLevel() - 9;
12805 
12806  if (getClass() != CLASS_DEATH_KNIGHT || GetMapId() != 609)
12807  return uint32(base_talent * sWorld->getRate(RATE_TALENT));
12808 
12809  uint32 talentPointsForLevel = getLevel() < 56 ? 0 : getLevel() - 55;
12810  talentPointsForLevel += m_questRewardTalentCount;
12811 
12812  if (talentPointsForLevel > base_talent)
12813  talentPointsForLevel = base_talent;
12814 
12815  talentPointsForLevel += m_extraBonusTalentCount;
12816  return uint32(talentPointsForLevel * sWorld->getRate(RATE_TALENT));
12817 }
12818 
12819 bool Player::canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell) const
12820 {
12821  // continent checked in SpellInfo::CheckLocation at cast and area update
12822  uint32 v_map = GetVirtualMapForMapAndZone(mapid, zone);
12824  {
12825  if (!HasSpell(54197)) // 54197 = Cold Weather Flying
12826  {
12827  return false;
12828  }
12829  }
12830 
12831  return true;
12832 }
12833 
12835 {
12836  learnSpell(spellid);
12837 
12838  if (uint32 next = sSpellMgr->GetNextSpellInChain(spellid))
12839  learnSpellHighRank(next);
12840 }
12841 
12843 {
12844  // 0 1 2
12845  // SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", m_guid.GetCounter());
12846 
12847  uint32 count = 0;
12848  std::unordered_map<uint32, uint32> loadedSkillValues;
12849  if (result)
12850  {
12851  do
12852  {
12853  Field* fields = result->Fetch();
12854  uint16 skill = fields[0].GetUInt16();
12855  uint16 value = fields[1].GetUInt16();
12856  uint16 max = fields[2].GetUInt16();
12857 
12858  SkillRaceClassInfoEntry const* rcEntry = GetSkillRaceClassInfo(skill, getRace(), getClass());
12859  if (!rcEntry)
12860  {
12861  LOG_ERROR("entities.player", "Character %s has skill %u that does not exist.", GetGUID().ToString().c_str(), skill);
12862  continue;
12863  }
12864 
12865  // set fixed skill ranges
12866  switch (GetSkillRangeType(rcEntry))
12867  {
12868  case SKILL_RANGE_LANGUAGE: // 300..300
12869  value = max = 300;
12870  break;
12871  case SKILL_RANGE_MONO: // 1..1, grey monolite bar
12872  value = max = 1;
12873  break;
12874  case SKILL_RANGE_LEVEL:
12875  max = GetMaxSkillValueForLevel();
12876  default:
12877  break;
12878  }
12879 
12880  if (value == 0)
12881  {
12882  LOG_ERROR("entities.player", "Character %s has skill %u with value 0. Will be deleted.", GetGUID().ToString().c_str(), skill);
12883 
12885 
12886  stmt->setUInt32(0, GetGUID().GetCounter());
12887  stmt->setUInt16(1, skill);
12888 
12889  CharacterDatabase.Execute(stmt);
12890 
12891  continue;
12892  }
12893 
12894  uint16 skillStep = 0;
12895  if (SkillTiersEntry const* skillTier = sSkillTiersStore.LookupEntry(rcEntry->SkillTierID))
12896  {
12897  for (uint32 i = 0; i < MAX_SKILL_STEP; ++i)
12898  {
12899  if (skillTier->Value[skillStep] == max)
12900  {
12901  skillStep = i + 1;
12902  break;
12903  }
12904  }
12905  }
12906 
12907  SetUInt32Value(PLAYER_SKILL_INDEX(count), MAKE_PAIR32(skill, skillStep));
12908 
12911 
12912  mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED)));
12913 
12914  loadedSkillValues[skill] = value;
12915 
12916  ++count;
12917 
12918  if (count >= PLAYER_MAX_SKILLS) // client limit
12919  {
12920  LOG_ERROR("entities.player", "Character %s has more than %u skills.", GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS);
12921  break;
12922  }
12923  } while (result->NextRow());
12924  }
12925 
12926  // Learn skill rewarded spells after all skills have been loaded to prevent learning a skill from them before its loaded with proper value from DB
12927  for (auto& skill : loadedSkillValues)
12928  {
12929  learnSkillRewardedSpells(skill.first, skill.second);
12930  }
12931 
12932  for (; count < PLAYER_MAX_SKILLS; ++count)
12933  {
12937  }
12938 }
12939 
12941 {
12943 
12944  if (!phase)
12946 
12947  // some aura phases include 1 normal map in addition to phase itself
12948  uint32 n_phase = phase & ~PHASEMASK_NORMAL;
12949  if (n_phase > 0)
12950  return n_phase;
12951 
12952  return phase;
12953 }
12954 
12956 {
12957  ItemTemplate const* pProto = pItem->GetTemplate();
12958 
12959  // proto based limitations
12960  if (InventoryResult res = CanEquipUniqueItem(pProto, eslot, limit_count))
12961  return res;
12962 
12963  // check unique-equipped on gems
12964  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)
12965  {
12966  uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot));
12967  if (!enchant_id)
12968  continue;
12969  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
12970  if (!enchantEntry)
12971  continue;
12972 
12973  ItemTemplate const* pGem = sObjectMgr->GetItemTemplate(enchantEntry->GemID);
12974  if (!pGem)
12975  continue;
12976 
12977  // include for check equip another gems with same limit category for not equipped item (and then not counted)
12978  uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory
12979  ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1;
12980 
12981  if (InventoryResult res = CanEquipUniqueItem(pGem, eslot, gem_limit_count))
12982  return res;
12983  }
12984 
12985  return EQUIP_ERR_OK;
12986 }
12987 
12988 InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot, uint32 limit_count) const
12989 {
12990  // check unique-equipped on item
12991  if (itemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
12992  {
12993  // there is an equip limit on this item
12994  if (HasItemOrGemWithIdEquipped(itemProto->ItemId, 1, except_slot))
12996  }
12997 
12998  // check unique-equipped limit
12999  if (itemProto->ItemLimitCategory)
13000  {
13001  ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(itemProto->ItemLimitCategory);
13002  if (!limitEntry)
13004 
13005  // NOTE: limitEntry->mode not checked because if item have have-limit then it applied and to equip case
13006 
13007  if (limit_count > limitEntry->maxCount)
13009 
13010  // there is an equip limit on this item
13011  if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot))
13013  }
13014 
13015  return EQUIP_ERR_OK;
13016 }
13017 
13018 void Player::HandleFall(MovementInfo const& movementInfo)
13019 {
13020  // calculate total z distance of the fall
13021  float z_diff = m_lastFallZ - movementInfo.pos.GetPositionZ();
13022 
13023  //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
13024  // 14.57 can be calculated by resolving damageperc formula below to 0
13025  if (z_diff >= 14.57f && !isDead() && !IsGameMaster() && !GetCommandStatus(CHEAT_GOD) &&
13028  {
13029  //Safe fall, fall height reduction
13031 
13032  float damageperc = 0.018f * (z_diff - safe_fall) - 0.2426f;
13033  uint32 original_health = GetHealth(), final_damage = 0;
13034 
13035  if (damageperc > 0 && !IsImmunedToDamageOrSchool(SPELL_SCHOOL_MASK_NORMAL))
13036  {
13037  uint32 damage = (uint32)(damageperc * GetMaxHealth() * sWorld->getRate(RATE_DAMAGE_FALL));
13038 
13039  //float height = movementInfo.pos.m_positionZ;
13040  //UpdateGroundPositionZ(movementInfo.pos.m_positionX, movementInfo.pos.m_positionY, height);
13041 
13042  if (damage > 0)
13043  {
13044  //Prevent fall damage from being more than the player maximum health
13045  if (damage > GetMaxHealth())
13046  damage = GetMaxHealth();
13047 
13048  // Gust of Wind
13049  if (HasAura(43621))
13050  damage = GetMaxHealth() / 2;
13051 
13052  // Divine Protection
13053  if (HasAura(498))
13054  {
13055  damage /= 2;
13056  }
13057 
13058  final_damage = EnvironmentalDamage(DAMAGE_FALL, damage);
13059  }
13060 
13061  //Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction
13062  LOG_DEBUG("entities.player", "FALLDAMAGE mZ=%f z=%f fallTime=%u damage=%u SF=%d", movementInfo.pos.GetPositionZ(), GetPositionZ(), movementInfo.fallTime, damage, safe_fall);
13063  }
13064 
13065  // recheck alive, might have died of EnvironmentalDamage, avoid cases when player die in fact like Spirit of Redemption case
13066  if (IsAlive() && final_damage < original_health)
13068  }
13069 }
13070 
13072 {
13074 }
13075 
13077 {
13079 }
13080 
13082 {
13084 }
13085 
13086 bool Player::HasAchieved(uint32 achievementId) const
13087 {
13088  return m_achievementMgr->HasAchieved(achievementId);
13089 }
13090 
13092 {
13093  m_achievementMgr->StartTimedAchievement(type, entry, timeLost);
13094 }
13095 
13097 {
13099 }
13100 
13101 void Player::ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete /* = false*/)
13102 {
13103  m_achievementMgr->ResetAchievementCriteria(condition, value, evenIfCriteriaComplete);
13104 }
13105 
13107 {
13109 }
13110 
13111 void Player::LearnTalent(uint32 talentId, uint32 talentRank)
13112 {
13113  uint32 CurTalentPoints = GetFreeTalentPoints();
13114 
13115  // xinef: check basic data
13116  if (CurTalentPoints == 0)
13117  return;
13118 
13119  if (talentRank >= MAX_TALENT_RANK)
13120  return;
13121 
13122  TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
13123  if (!talentInfo)
13124  return;
13125 
13126  TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
13127  if (!talentTabInfo)
13128  return;
13129 
13130  // xinef: prevent learn talent for different class (cheating)
13131  if ((getClassMask() & talentTabInfo->ClassMask) == 0)
13132  return;
13133 
13134  // xinef: find current talent rank
13135  uint32 currentTalentRank = 0;
13136  for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
13137  {
13138  if (talentInfo->RankID[rank] && HasTalent(talentInfo->RankID[rank], GetActiveSpec()))
13139  {
13140  currentTalentRank = rank + 1;
13141  break;
13142  }
13143  }
13144 
13145  // xinef: we already have same or higher rank talent learned
13146  if (currentTalentRank >= talentRank + 1)
13147  return;
13148 
13149  // xinef: check if we have enough free talent points
13150  uint32 talentPointsChange = (talentRank - currentTalentRank + 1);
13151  if (CurTalentPoints < talentPointsChange)
13152  return;
13153 
13154  // xinef: check if talent deponds on another talent
13155  if (talentInfo->DependsOn > 0)
13156  if (TalentEntry const* depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
13157  {
13158  bool hasEnoughRank = false;
13159  for (uint8 rank = talentInfo->DependsOnRank; rank < MAX_TALENT_RANK; rank++)
13160  {
13161  if (depTalentInfo->RankID[rank] != 0)
13162  if (HasTalent(depTalentInfo->RankID[rank], GetActiveSpec()))
13163  {
13164  hasEnoughRank = true;
13165  break;
13166  }
13167  }
13168 
13169  // xinef: does not have enough talent points spend in required talent
13170  if (!hasEnoughRank)
13171  return;
13172  }
13173 
13174  // xinef: check amount of points spent in current talent tree
13175  // xinef: be smart and quick
13176  uint32 spentPoints = 0;
13177  if (talentInfo->Row > 0)
13178  {
13179  const PlayerTalentMap& talentMap = GetTalentMap();
13180  for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
13181  if (TalentSpellPos const* talentPos = GetTalentSpellPos(itr->first))
13182  if (TalentEntry const* itrTalentInfo = sTalentStore.LookupEntry(talentPos->talent_id))
13183  if (itrTalentInfo->TalentTab == talentInfo->TalentTab)
13184  if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(GetActiveSpec())) // pussywizard
13185  spentPoints += talentPos->rank + 1;
13186  }
13187 
13188  // xinef: we do not have enough talent points to add talent of this tier
13189  if (spentPoints < (talentInfo->Row * MAX_TALENT_RANK))
13190  return;
13191 
13192  // xinef: hacking attempt, tries to learn unknown rank
13193  uint32 spellId = talentInfo->RankID[talentRank];
13194  if (spellId == 0)
13195  return;
13196 
13197  const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
13198  if (!spellInfo)
13199  return;
13200 
13201  bool learned = false;
13202 
13203  // xinef: if talent info has special marker in dbc - add to spell book
13204  if (talentInfo->addToSpellBook)
13205  if (!spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL))
13206  {
13207  learnSpell(spellId);
13208  learned = true;
13209  }
13210 
13211  if (!learned)
13212  SendLearnPacket(spellId, true);
13213 
13214  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
13215  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
13216  if (sSpellMgr->IsAdditionalTalentSpell(spellInfo->Effects[i].TriggerSpell))
13217  learnSpell(spellInfo->Effects[i].TriggerSpell);
13218 
13219  addTalent(spellId, GetActiveSpecMask(), currentTalentRank);
13220 
13221  // xinef: update free talent points count
13222  m_usedTalentCount += talentPointsChange;
13223  SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
13224 
13225 #ifdef ELUNA
13226  sEluna->OnLearnTalents(this, talentId, talentRank, spellId);
13227 #endif
13228 }
13229 
13230 void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank)
13231 {
13232  Pet* pet = GetPet();
13233 
13234  if (!pet)
13235  return;
13236 
13237  if (petGuid != pet->GetGUID())
13238  return;
13239 
13240  uint32 CurTalentPoints = pet->GetFreeTalentPoints();
13241 
13242  if (CurTalentPoints == 0)
13243  return;
13244 
13245  if (talentRank >= MAX_PET_TALENT_RANK)
13246  return;
13247 
13248  TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
13249 
13250  if (!talentInfo)
13251  return;
13252 
13253  TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
13254 
13255  if (!talentTabInfo)
13256  return;
13257 
13258  CreatureTemplate const* ci = pet->GetCreatureTemplate();
13259 
13260  if (!ci)
13261  return;
13262 
13263  CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
13264 
13265  if (!pet_family)
13266  return;
13267 
13268  if (pet_family->petTalentType < 0) // not hunter pet
13269  return;
13270 
13271  // prevent learn talent for different family (cheating)
13272  if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
13273  return;
13274 
13275  // find current max talent rank (0~5)
13276  uint8 curtalent_maxrank = 0; // 0 = not learned any rank
13277  for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
13278  {
13279  if (talentInfo->RankID[rank] && pet->HasSpell(talentInfo->RankID[rank]))
13280  {
13281  curtalent_maxrank = (rank + 1);
13282  break;
13283  }
13284  }
13285 
13286  // we already have same or higher talent rank learned
13287  if (curtalent_maxrank >= (talentRank + 1))
13288  return;
13289 
13290  // check if we have enough talent points
13291  if (CurTalentPoints < (talentRank - curtalent_maxrank + 1))
13292  return;
13293 
13294  // Check if it requires another talent
13295  if (talentInfo->DependsOn > 0)
13296  {
13297  if (TalentEntry const* depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
13298  {
13299  bool hasEnoughRank = false;
13300  for (uint8 rank = talentInfo->DependsOnRank; rank < MAX_TALENT_RANK; rank++)
13301  {
13302  if (depTalentInfo->RankID[rank] != 0)
13303  if (pet->HasSpell(depTalentInfo->RankID[rank]))
13304  hasEnoughRank = true;
13305  }
13306  if (!hasEnoughRank)
13307  return;
13308  }
13309  }
13310 
13311  // Find out how many points we have in this field
13312  uint32 spentPoints = 0;
13313 
13314  uint32 tTab = talentInfo->TalentTab;
13315  if (talentInfo->Row > 0)
13316  {
13317  uint32 numRows = sTalentStore.GetNumRows();
13318  for (uint32 i = 0; i < numRows; ++i) // Loop through all talents.
13319  {
13320  // Someday, someone needs to revamp
13321  const TalentEntry* tmpTalent = sTalentStore.LookupEntry(i);
13322  if (tmpTalent) // the way talents are tracked
13323  {
13324  if (tmpTalent->TalentTab == tTab)
13325  {
13326  for (uint8 rank = 0; rank < MAX_TALENT_RANK; rank++)
13327  {
13328  if (tmpTalent->RankID[rank] != 0)
13329  {
13330  if (pet->HasSpell(tmpTalent->RankID[rank]))
13331  {
13332  spentPoints += (rank + 1);
13333  }
13334  }
13335  }
13336  }
13337  }
13338  }
13339  }
13340 
13341  // not have required min points spent in talent tree
13342  if (spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK))
13343  return;
13344 
13345  // spell not set in talent.dbc
13346  uint32 spellid = talentInfo->RankID[talentRank];
13347  if (spellid == 0)
13348  {
13349  LOG_ERROR("entities.player", "Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank);
13350  return;
13351  }
13352 
13353  // already known
13354  if (pet->HasSpell(spellid))
13355  return;
13356 
13357  // learn! (other talent ranks will unlearned at learning)
13358  pet->learnSpell(spellid);
13359  LOG_DEBUG("entities.player", "PetTalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
13360 
13361  // update free talent points
13362  pet->SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1));
13363 }
13364 
13366 {
13367  if (CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId))
13368  SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (1LL << (ctEntry->BitIndex - 1)));
13369 }
13370 
13372 {
13373  Pet* pet = GetPet();
13374  if (!pet || !pet->IsInWorld())
13375  return;
13376 
13378  {
13381  }
13382 
13384 }
13385 
13387 {
13389  return;
13390 
13391  // not resummon in not appropriate state
13393  return;
13394 
13395  if (GetPetGUID())
13396  return;
13397 
13399  return;
13400 
13402  //m_temporaryUnsummonedPetNumber = 0;
13403 }
13404 
13406 {
13407  if (getClass() == CLASS_DEATH_KNIGHT)
13408  {
13409  if (CanSeeDKPet())
13410  return true;
13411  else if (spellid == 52150)
13412  return false;
13413  }
13414  else if (getClass() == CLASS_HUNTER || getClass() == CLASS_MAGE)
13415  return true;
13416 
13417  if (!HasSpell(spellid))
13418  return false;
13419 
13420  return true;
13421 }
13422 
13424 {
13426  return false;
13427 
13428  SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(c->GetEntry());
13429  if (clickPair.first == clickPair.second)
13430  return true;
13431 
13432  for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
13433  {
13434  if (!itr->second.IsFitToRequirements(this, c))
13435  return false;
13436 
13437  ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(c->GetEntry(), itr->second.spellId);
13438  ConditionSourceInfo info = ConditionSourceInfo(const_cast<Player*>(this), const_cast<Creature*>(c));
13439  if (sConditionMgr->IsObjectMeetToConditions(info, conds))
13440  return true;
13441  }
13442 
13443  return false;
13444 }
13445 
13447 {
13448  *data << uint32(GetFreeTalentPoints()); // unspentTalentPoints
13449  *data << uint8(m_specsCount); // talent group count (0, 1 or 2)
13450  *data << uint8(m_activeSpec); // talent group index (0 or 1)
13451 
13454 
13455  for (uint32 specIdx = 0; specIdx < m_specsCount; ++specIdx)
13456  {
13457  uint8 talentIdCount = 0;
13458  size_t pos = data->wpos();
13459  *data << uint8(talentIdCount); // [PH], talentIdCount
13460 
13461  const PlayerTalentMap& talentMap = GetTalentMap();
13462  for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
13463  if (TalentSpellPos const* talentPos = GetTalentSpellPos(itr->first))
13464  if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(specIdx)) // pussywizard
13465  {
13466  *data << uint32(talentPos->talent_id); // Talent.dbc
13467  *data << uint8(talentPos->rank); // talentMaxRank (0-4)
13468  ++talentIdCount;
13469  }
13470 
13471  data->put<uint8>(pos, talentIdCount); // put real count
13472 
13473  *data << uint8(MAX_GLYPH_SLOT_INDEX); // glyphs count
13474 
13475  for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
13476  *data << uint16(m_Glyphs[specIdx][i]); // GlyphProperties.dbc
13477  }
13478 }
13479 
13481 {
13482  uint32 unspentTalentPoints = 0;
13483  size_t pointsPos = data->wpos();
13484  *data << uint32(unspentTalentPoints); // [PH], unspentTalentPoints
13485 
13486  uint8 talentIdCount = 0;
13487  size_t countPos = data->wpos();
13488  *data << uint8(talentIdCount); // [PH], talentIdCount
13489 
13490  Pet* pet = GetPet();
13491  if (!pet)
13492  return;
13493 
13494  unspentTalentPoints = pet->GetFreeTalentPoints();
13495 
13496  data->put<uint32>(pointsPos, unspentTalentPoints); // put real points
13497 
13498  CreatureTemplate const* ci = pet->GetCreatureTemplate();
13499  if (!ci)
13500  return;
13501 
13502  CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
13503  if (!pet_family || pet_family->petTalentType < 0)
13504  return;
13505 
13506  for (uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId)
13507  {
13508  TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentTabId);
13509  if (!talentTabInfo)
13510  continue;
13511 
13512  if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
13513  continue;
13514 
13515  for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
13516  {
13517  TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
13518  if (!talentInfo)
13519  continue;
13520 
13521  // skip another tab talents
13522  if (talentInfo->TalentTab != talentTabId)
13523  continue;
13524 
13525  // find max talent rank (0~4)
13526  int8 curtalent_maxrank = -1;
13527  for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
13528  {
13529  if (talentInfo->RankID[rank] && pet->HasSpell(talentInfo->RankID[rank]))
13530  {
13531  curtalent_maxrank = rank;
13532  break;
13533  }
13534  }
13535 
13536  // not learned talent
13537  if (curtalent_maxrank < 0)
13538  continue;
13539 
13540  *data << uint32(talentInfo->TalentID); // Talent.dbc
13541  *data << uint8(curtalent_maxrank); // talentMaxRank (0-4)
13542 
13543  ++talentIdCount;
13544  }
13545 
13546  data->put<uint8>(countPos, talentIdCount); // put real count
13547 
13548  break;
13549  }
13550 }
13551 
13553 {
13554  WorldPacket data(SMSG_TALENTS_INFO, 50);
13555  data << uint8(pet ? 1 : 0);
13556  if (pet)
13557  BuildPetTalentsInfoData(&data);
13558  else
13560  GetSession()->SendPacket(&data);
13561 }
13562 
13564 {
13565  uint32 slotUsedMask = 0;
13566  size_t slotUsedMaskPos = data->wpos();
13567  *data << uint32(slotUsedMask); // slotUsedMask < 0x80000
13568 
13569  for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
13570  {
13572 
13573  if (!item)
13574  continue;
13575 
13576  slotUsedMask |= (1 << i);
13577 
13578  *data << uint32(item->GetEntry()); // item entry
13579 
13580  uint16 enchantmentMask = 0;
13581  size_t enchantmentMaskPos = data->wpos();
13582  *data << uint16(enchantmentMask); // enchantmentMask < 0x1000
13583 
13584  for (uint32 j = 0; j < MAX_ENCHANTMENT_SLOT; ++j)
13585  {
13586  uint32 enchId = item->GetEnchantmentId(EnchantmentSlot(j));
13587 
13588  if (!enchId)
13589  continue;
13590 
13591  enchantmentMask |= (1 << j);
13592 
13593  *data << uint16(enchId); // enchantmentId?
13594  }
13595 
13596  data->put<uint16>(enchantmentMaskPos, enchantmentMask);
13597 
13598  *data << int16(item->GetItemRandomPropertyId()); // item random property id
13599  *data << item->GetGuidValue(ITEM_FIELD_CREATOR).WriteAsPacked(); // item creator
13600  *data << uint32(item->GetItemSuffixFactor()); // item suffix factor
13601  }
13602 
13603  data->put<uint32>(slotUsedMaskPos, slotUsedMask);
13604 }
13605 
13607 {
13608  uint32 count = 0;
13610  size_t count_pos = data.wpos();
13611  data << uint32(count); // count placeholder
13612  for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr)
13613  {
13614  if (itr->second.state == EQUIPMENT_SET_DELETED)
13615  continue;
13616 
13617  data.appendPackGUID(itr->second.Guid);
13618  data << uint32(itr->first);
13619  data << itr->second.Name;
13620  data << itr->second.IconName;
13621  for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
13622  {
13623  // ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HighGuid::Item
13624  if (itr->second.IgnoreMask & (1 << i))
13625  data.appendPackGUID(uint64(1));
13626  else // xinef: send proper data (do not append 0 with high guid)
13627  data.appendPackGUID(itr->second.Items[i] ? itr->second.Items[i].GetRawValue() : uint64(0));
13628  }
13629 
13630  ++count; // client have limit but it checked at loading and set
13631  }
13632  data.put<uint32>(count_pos, count);
13633  GetSession()->SendPacket(&data);
13634 }
13635 
13637 {
13638  if (eqset.Guid != 0)
13639  {
13640  bool found = false;
13641 
13642  for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr)
13643  {
13644  if ((itr->second.Guid == eqset.Guid) && (itr->first == index))
13645  {
13646  found = true;
13647  break;
13648  }
13649  }
13650 
13651  if (!found) // something wrong...
13652  {
13653  LOG_ERROR("entities.player", "Player %s tried to save equipment set " UI64FMTD " (index %u), but that equipment set not found!", GetName().c_str(), eqset.Guid, index);
13654  return;
13655  }
13656  }
13657 
13658  EquipmentSet& eqslot = m_EquipmentSets[index];
13659 
13660  EquipmentSetUpdateState old_state = eqslot.state;
13661 
13662  eqslot = eqset;
13663 
13664  if (eqset.Guid == 0)
13665  {
13666  eqslot.Guid = sObjectMgr->GenerateEquipmentSetGuid();
13667 
13669  data << uint32(index);
13670  data.appendPackGUID(eqslot.Guid);
13671  GetSession()->SendPacket(&data);
13672  }
13673 
13675 }
13676 
13678 {
13679  for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end();)
13680  {
13681  uint32 index = itr->first;
13682  EquipmentSet& eqset = itr->second;
13683  CharacterDatabasePreparedStatement* stmt = nullptr;
13684  uint8 j = 0;
13685  switch (eqset.state)
13686  {
13688  ++itr;
13689  break; // nothing do
13690  case EQUIPMENT_SET_CHANGED:
13691  stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_EQUIP_SET);
13692  stmt->setString(j++, eqset.Name.c_str());
13693  stmt->setString(j++, eqset.IconName.c_str());
13694  stmt->setUInt32(j++, eqset.IgnoreMask);
13695  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
13696  stmt->setUInt32(j++, eqset.Items[i].GetCounter());
13697  stmt->setUInt32(j++, GetGUID().GetCounter());
13698  stmt->setUInt64(j++, eqset.Guid);
13699  stmt->setUInt32(j, index);
13700  trans->Append(stmt);
13702  ++itr;
13703  break;
13704  case EQUIPMENT_SET_NEW:
13705  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_EQUIP_SET);
13706  stmt->setUInt32(j++, GetGUID().GetCounter());
13707  stmt->setUInt64(j++, eqset.Guid);
13708  stmt->setUInt32(j++, index);
13709  stmt->setString(j++, eqset.Name.c_str());
13710  stmt->setString(j++, eqset.IconName.c_str());
13711  stmt->setUInt32(j++, eqset.IgnoreMask);
13712  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
13713  stmt->setUInt32(j++, eqset.Items[i].GetCounter());
13714  trans->Append(stmt);
13716  ++itr;
13717  break;
13718  case EQUIPMENT_SET_DELETED:
13719  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EQUIP_SET);
13720  stmt->setUInt64(0, eqset.Guid);
13721  trans->Append(stmt);
13722  m_EquipmentSets.erase(itr++);
13723  break;
13724  }
13725  }
13726 }
13727 
13729 {
13730  // xinef: dont save joinpos with invalid mapid
13731  MapEntry const* mEntry = sMapStore.LookupEntry(m_entryPointData.joinPos.GetMapId());
13732  if (!mEntry)
13733  return;
13734 
13736  stmt->setUInt32(0, GetGUID().GetCounter());
13737  trans->Append(stmt);
13738 
13739  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_ENTRY_POINT);
13740  stmt->setUInt32(0, GetGUID().GetCounter());
13746 
13747  std::ostringstream ss("");
13749  {
13750  for (size_t i = 0; i < m_entryPointData.taxiPath.size(); ++i)
13751  ss << m_entryPointData.taxiPath[i] << ' '; // xinef: segment is stored as last point
13752  }
13753 
13754  stmt->setString(6, ss.str());
13756  trans->Append(stmt);
13757 }
13758 
13760 {
13761  for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr)
13762  {
13763  if (itr->second.Guid == setGuid)
13764  {
13765  if (itr->second.state == EQUIPMENT_SET_NEW)
13766  m_EquipmentSets.erase(itr);
13767  else
13768  itr->second.state = EQUIPMENT_SET_DELETED;
13769  break;
13770  }
13771  }
13772 }
13773 
13774 void Player::RemoveAtLoginFlag(AtLoginFlags flags, bool persist /*= false*/)
13775 {
13776  m_atLoginFlags &= ~flags;
13777 
13778  if (persist)
13779  {
13781 
13782  stmt->setUInt16(0, uint16(flags));
13783  stmt->setUInt32(1, GetGUID().GetCounter());
13784 
13785  CharacterDatabase.Execute(stmt);
13786  }
13787 }
13788 
13789 void Player::SendClearCooldown(uint32 spell_id, Unit* target)
13790 {
13791  WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8);
13792  data << uint32(spell_id);
13793  data << target->GetGUID();
13794  SendDirectMessage(&data);
13795 
13796  if (target == this && NeedSendSpectatorData())
13798 }
13799 
13801 {
13802  // this may be called during Map::Update
13803  // after decrement+unlink, ++m_mapRefIter will continue correctly
13804  // when the first element of the list is being removed
13805  // nocheck_prev will return the padding element of the RefMgr
13806  // instead of nullptr in the case of prev
13807  GetMap()->UpdateIteratorBack(this);
13808  Unit::ResetMap();
13809  GetMapRef().unlink();
13810 }
13811 
13813 {
13814  Unit::SetMap(map);
13815  m_mapRef.link(map, this);
13816 }
13817 
13819 {
13820  CharacterDatabasePreparedStatement* stmt = nullptr;
13821  uint8 index = 0;
13822 
13823  auto finiteAlways = [](float f) { return std::isfinite(f) ? f : 0.0f; };
13824 
13825  if (create)
13826  {
13829  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER);
13830  stmt->setUInt32(index++, GetGUID().GetCounter());
13831  stmt->setUInt32(index++, GetSession()->GetAccountId());
13832  stmt->setString(index++, GetName());
13833  stmt->setUInt8(index++, getRace(true));
13834  stmt->setUInt8(index++, getClass());
13835  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
13836  stmt->setUInt8(index++, getLevel());
13837  stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
13838  stmt->setUInt32(index++, GetMoney());
13839  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 0));
13840  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 1));
13841  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 2));
13842  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 3));
13843  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 0));
13844  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 2));
13845  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 3));
13846  stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
13847  stmt->setUInt16(index++, (uint16)GetMapId());
13848  stmt->setUInt32(index++, (uint32)GetInstanceId());
13849  stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
13850  stmt->setFloat(index++, finiteAlways(GetPositionX()));
13851  stmt->setFloat(index++, finiteAlways(GetPositionY()));
13852  stmt->setFloat(index++, finiteAlways(GetPositionZ()));
13853  stmt->setFloat(index++, finiteAlways(GetOrientation()));
13854  stmt->setFloat(index++, finiteAlways(GetTransOffsetX()));
13855  stmt->setFloat(index++, finiteAlways(GetTransOffsetY()));
13856  stmt->setFloat(index++, finiteAlways(GetTransOffsetZ()));
13857  stmt->setFloat(index++, finiteAlways(GetTransOffsetO()));
13858 
13859  int32 lowGuidOrSpawnId = 0;
13860  if (Transport* transport = GetTransport())
13861  {
13862  if (transport->IsMotionTransport())
13863  lowGuidOrSpawnId = static_cast<int32>(transport->GetGUID().GetCounter());
13864  else if (transport->IsStaticTransport())
13865  lowGuidOrSpawnId = -static_cast<int32>(transport->GetSpawnId());
13866  }
13867  stmt->setInt32(index++, lowGuidOrSpawnId);
13868 
13869  std::ostringstream ss;
13870  ss << m_taxi;
13871  stmt->setString(index++, ss.str());
13872  stmt->setUInt8(index++, m_cinematic);
13873  stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
13874  stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
13875  stmt->setFloat(index++, finiteAlways(_restBonus));
13876  stmt->setUInt32(index++, uint32(time(nullptr)));
13877  stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
13878  //save, far from tavern/city
13879  //save, but in tavern/city
13880  stmt->setUInt32(index++, m_resetTalentsCost);
13881  stmt->setUInt32(index++, uint32(m_resetTalentsTime));
13882  stmt->setUInt16(index++, (uint16)m_ExtraFlags);
13883  stmt->setUInt8(index++, m_stableSlots);
13884  stmt->setUInt16(index++, (uint16)m_atLoginFlags);
13885  stmt->setUInt16(index++, GetZoneId());
13886  stmt->setUInt32(index++, uint32(m_deathExpireTime));
13887 
13888  ss.str("");
13890 
13891  stmt->setString(index++, ss.str());
13892  stmt->setUInt32(index++, GetArenaPoints());
13893  stmt->setUInt32(index++, GetHonorPoints());
13897  stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0));
13898  stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1));
13899  stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
13902  stmt->setUInt8(index++, GetDrunkValue());
13903  stmt->setUInt32(index++, GetHealth());
13904 
13905  for (uint32 i = 0; i < MAX_POWERS; ++i)
13906  stmt->setUInt32(index++, GetPower(Powers(i)));
13907 
13908  stmt->setUInt32(index++, GetSession()->GetLatency());
13909 
13910  stmt->setUInt8(index++, m_specsCount);
13911  stmt->setUInt8(index++, m_activeSpec);
13912 
13913  ss.str("");
13914  for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
13915  ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
13916  stmt->setString(index++, ss.str());
13917 
13918  ss.str("");
13919  // cache equipment...
13920  for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i)
13922 
13923  // ...and bags for enum opcode
13925  {
13926  if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
13927  ss << item->GetEntry();
13928  else
13929  ss << '0';
13930  ss << " 0 ";
13931  }
13932 
13933  stmt->setString(index++, ss.str());
13934  stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID));
13935 
13936  ss.str("");
13937  for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i)
13938  ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
13939 
13940  stmt->setString(index++, ss.str());
13941  stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2));
13942  stmt->setUInt32(index++, m_grantableLevels);
13943  stmt->setUInt32(index++, _innTriggerId);
13944  }
13945  else
13946  {
13947  // Update query
13948  stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER);
13949  stmt->setString(index++, GetName());
13950  stmt->setUInt8(index++, getRace(true));
13951  stmt->setUInt8(index++, getClass());
13952  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
13953  stmt->setUInt8(index++, getLevel());
13954  stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
13955  stmt->setUInt32(index++, GetMoney());
13956  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 0));
13957  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 1));
13958  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 2));
13959  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, 3));
13960  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 0));
13961  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 2));
13962  stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, 3));
13963  stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
13964 
13965  if (!IsBeingTeleported())
13966  {
13968  if (Map* m = FindMap())
13969  if (m->IsDungeon())
13970  {
13971  if (m->IsNonRaidDungeon()) dd = m->GetDifficulty();
13972  else rd = m->GetDifficulty();
13973  }
13974  stmt->setUInt16(index++, (uint16)GetMapId());
13975  stmt->setUInt32(index++, (uint32)GetInstanceId());
13976  stmt->setUInt8(index++, (uint8(dd) | uint8(rd) << 4));
13977  stmt->setFloat(index++, finiteAlways(GetPositionX()));
13978  stmt->setFloat(index++, finiteAlways(GetPositionY()));
13979  stmt->setFloat(index++, finiteAlways(GetPositionZ()));
13980  stmt->setFloat(index++, finiteAlways(GetOrientation()));
13981  }
13982  else
13983  {
13984  stmt->setUInt16(index++, (uint16)GetTeleportDest().GetMapId());
13985  stmt->setUInt32(index++, (uint32)0);
13986  stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
13987  stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionX()));
13988  stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionY()));
13989  stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionZ()));
13990  stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetOrientation()));
13991  }
13992 
13993  stmt->setFloat(index++, finiteAlways(GetTransOffsetX()));
13994  stmt->setFloat(index++, finiteAlways(GetTransOffsetY()));
13995  stmt->setFloat(index++, finiteAlways(GetTransOffsetZ()));
13996  stmt->setFloat(index++, finiteAlways(GetTransOffsetO()));
13997 
13998  int32 lowGuidOrSpawnId = 0;
13999  if (Transport* transport = GetTransport())
14000  {
14001  if (transport->IsMotionTransport())
14002  lowGuidOrSpawnId = static_cast<int32>(transport->GetGUID().GetCounter());
14003  else if (transport->IsStaticTransport())
14004  lowGuidOrSpawnId = -static_cast<int32>(transport->GetSpawnId());
14005  }
14006  stmt->setInt32(index++, lowGuidOrSpawnId);
14007 
14008  std::ostringstream ss;
14009  ss << m_taxi;
14010  stmt->setString(index++, ss.str());
14011  stmt->setUInt8(index++, m_cinematic);
14012  stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
14013  stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
14014  stmt->setFloat(index++, finiteAlways(_restBonus));
14015  stmt->setUInt32(index++, uint32(time(nullptr)));
14016  stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
14017  //save, far from tavern/city
14018  //save, but in tavern/city
14019  stmt->setUInt32(index++, m_resetTalentsCost);
14020  stmt->setUInt32(index++, uint32(m_resetTalentsTime));
14021  stmt->setUInt16(index++, (uint16)m_ExtraFlags);
14022  stmt->setUInt8(index++, m_stableSlots);
14023  stmt->setUInt16(index++, (uint16)m_atLoginFlags);
14024  stmt->setUInt16(index++, GetZoneId());
14025  stmt->setUInt32(index++, uint32(m_deathExpireTime));
14026 
14027  ss.str("");
14029 
14030  stmt->setString(index++, ss.str());
14031  stmt->setUInt32(index++, GetArenaPoints());
14032  stmt->setUInt32(index++, GetHonorPoints());
14036  stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0));
14037  stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1));
14038  stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
14041  stmt->setUInt8(index++, GetDrunkValue());
14042  stmt->setUInt32(index++, GetHealth());
14043 
14044  for (uint32 i = 0; i < MAX_POWERS; ++i)
14045  stmt->setUInt32(index++, GetPower(Powers(i)));
14046 
14047  stmt->setUInt32(index++, GetSession()->GetLatency());
14048 
14049  stmt->setUInt8(index++, m_specsCount);
14050  stmt->setUInt8(index++, m_activeSpec);
14051 
14052  ss.str("");
14053  for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
14054  ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
14055  stmt->setString(index++, ss.str());
14056 
14057  ss.str("");
14058  // cache equipment...
14059  for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i)
14061 
14062  // ...and bags for enum opcode
14064  {
14065  if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
14066  ss << item->GetEntry();
14067  else
14068  ss << '0';
14069  ss << " 0 ";
14070  }
14071 
14072  stmt->setString(index++, ss.str());
14073  stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID));
14074 
14075  ss.str("");
14076  for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i)
14077  ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
14078 
14079  stmt->setString(index++, ss.str());
14080  stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2));
14081  stmt->setUInt32(index++, m_grantableLevels);
14082  stmt->setUInt32(index++, _innTriggerId);
14083 
14084  stmt->setUInt8(index++, IsInWorld() && !GetSession()->PlayerLogout() ? 1 : 0);
14085  // Index
14086  stmt->setUInt32(index++, GetGUID().GetCounter());
14087  }
14088 
14089  trans->Append(stmt);
14090 }
14091 
14093 {
14094  // SELECT talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 from character_glyphs WHERE guid = '%u'
14095  if (!result)
14096  return;
14097 
14098  do
14099  {
14100  Field* fields = result->Fetch();
14101 
14102  uint8 spec = fields[0].GetUInt8();
14103  if (spec >= m_specsCount)
14104  continue;
14105 
14106  m_Glyphs[spec][0] = fields[1].GetUInt16();
14107  m_Glyphs[spec][1] = fields[2].GetUInt16();
14108  m_Glyphs[spec][2] = fields[3].GetUInt16();
14109  m_Glyphs[spec][3] = fields[4].GetUInt16();
14110  m_Glyphs[spec][4] = fields[5].GetUInt16();
14111  m_Glyphs[spec][5] = fields[6].GetUInt16();
14112  } while (result->NextRow());
14113 }
14114 
14116 {
14117  if (!NeedToSaveGlyphs())
14118  return;
14119 
14121  stmt->setUInt32(0, GetGUID().GetCounter());
14122  trans->Append(stmt);
14123 
14124  for (uint8 spec = 0; spec < m_specsCount; ++spec)
14125  {
14126  uint8 index = 0;
14127 
14128  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GLYPHS);
14129  stmt->setUInt32(index++, GetGUID().GetCounter());
14130  stmt->setUInt8(index++, spec);
14131 
14132  for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
14133  stmt->setUInt16(index++, uint16(m_Glyphs[spec][i]));
14134 
14135  trans->Append(stmt);
14136  }
14137 
14138  SetNeedToSaveGlyphs(false);
14139 }
14140 
14142 {
14143  // SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, specMask FROM character_talent WHERE guid = '%u'", m_guid.GetCounter());
14144  if (result)
14145  {
14146  do
14147  {
14148  // xinef: checked
14149  uint32 spellId = (*result)[0].GetUInt32();
14150  uint8 specMask = (*result)[1].GetUInt8();
14151  addTalent(spellId, specMask, 0);
14152  TalentSpellPos const* talentPos = GetTalentSpellPos(spellId);
14153  ASSERT(talentPos);
14154 
14155  // xinef: increase used talent points count
14156  if (GetActiveSpecMask() & specMask)
14157  m_usedTalentCount += talentPos->rank + 1;
14158  } while (result->NextRow());
14159  }
14160 }
14161 
14163 {
14164  CharacterDatabasePreparedStatement* stmt = nullptr;
14165 
14166  for (PlayerTalentMap::iterator itr = m_talents.begin(); itr != m_talents.end();)
14167  {
14168  // xinef: skip temporary spells
14169  if (itr->second->State == PLAYERSPELL_TEMPORARY)
14170  {
14171  ++itr;
14172  continue;
14173  }
14174 
14175  // xinef: delete statement for removed / updated talent
14176  if (itr->second->State == PLAYERSPELL_REMOVED || itr->second->State == PLAYERSPELL_CHANGED)
14177  {
14178  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT_BY_SPELL);
14179  stmt->setUInt32(0, GetGUID().GetCounter());
14180  stmt->setUInt32(1, itr->first);
14181  trans->Append(stmt);
14182  }
14183 
14184  // xinef: insert statement for new / updated spell
14185  if (itr->second->State == PLAYERSPELL_NEW || itr->second->State == PLAYERSPELL_CHANGED)
14186  {
14187  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_TALENT);
14188  stmt->setUInt32(0, GetGUID().GetCounter());
14189  stmt->setUInt32(1, itr->first);
14190  stmt->setUInt8(2, itr->second->specMask);
14191  trans->Append(stmt);
14192  }
14193 
14194  if (itr->second->State == PLAYERSPELL_REMOVED)
14195  {
14196  delete itr->second;
14197  m_talents.erase(itr++);
14198  }
14199  else
14200  {
14201  itr->second->State = PLAYERSPELL_UNCHANGED;
14202  ++itr;
14203  }
14204  }
14205 }
14206 
14208 {
14209  // xinef: some basic checks
14210  if (GetActiveSpec() == spec)
14211  return;
14212 
14213  if (spec > GetSpecsCount())
14214  return;
14215 
14216  // xinef: interrupt currently casted spell just in case
14217  if (IsNonMeleeSpellCast(false))
14218  InterruptNonMeleeSpells(false);
14219 
14220  // xinef: save current actions order
14221  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
14222  _SaveActions(trans);
14223  CharacterDatabase.CommitTransaction(trans);
14224 
14225  // xinef: remove pet, it will be resummoned later
14226  if (Pet* pet = GetPet())
14228 
14229  // xinef: remove other summoned units and clear reactives
14233 
14234  // xinef: let client clear his current Actions
14235  SendActionButtons(2);
14236  uint8 oldSpec = GetActiveSpec();
14237 
14238  std::unordered_set<uint32> removedSpecAuras;
14239 
14240  // xinef: reset talent auras
14241  for (PlayerTalentMap::iterator itr = m_talents.begin(); itr != m_talents.end(); ++itr)
14242  {
14243  if (itr->second->State == PLAYERSPELL_REMOVED)
14244  continue;
14245 
14246  // xinef: remove all active talent auras
14247  if (!(itr->second->specMask & GetActiveSpecMask()))
14248  continue;
14249 
14250  _removeTalentAurasAndSpells(itr->first);
14251 
14252  // pussywizard: was => isn't
14253  if (!itr->second->IsInSpec(spec) && !itr->second->inSpellBook)
14254  SendLearnPacket(itr->first, false);
14255 
14256  removedSpecAuras.insert(itr->first);
14257  }
14258 
14259  // xinef: remove glyph auras
14260  for (uint8 slot = 0; slot < MAX_GLYPH_SLOT_INDEX; ++slot)
14261  if (uint32 glyphId = m_Glyphs[GetActiveSpec()][slot])
14262  if (GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyphId))
14263  {
14264  RemoveAurasDueToSpell(glyphEntry->SpellId);
14265  removedSpecAuras.insert(glyphEntry->SpellId);
14266  }
14267 
14268  // xinef: set active spec as new one
14269  SetActiveSpec(spec);
14270  uint32 spentTalents = 0;
14271 
14272  // xinef: add talent auras
14273  for (PlayerTalentMap::iterator itr = m_talents.begin(); itr != m_talents.end(); ++itr)
14274  {
14275  if (itr->second->State == PLAYERSPELL_REMOVED)
14276  continue;
14277 
14278  // xinef: talent not in new spec
14279  if (!(itr->second->specMask & GetActiveSpecMask()))
14280  continue;
14281 
14282  // pussywizard: wasn't => is
14283  if (!itr->second->IsInSpec(oldSpec) && !itr->second->inSpellBook)
14284  SendLearnPacket(itr->first, true);
14285 
14286  _addTalentAurasAndSpells(itr->first);
14287  TalentSpellPos const* talentPos = GetTalentSpellPos(itr->first);
14288  spentTalents += talentPos->rank + 1;
14289 
14290  removedSpecAuras.erase(itr->first);
14291  }
14292 
14293  // pussywizard: remove spells that are in previous spec, but are not present in new one (or are in new spec, but not in the old one)
14294  for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
14295  {
14296  if (!itr->second->Active || itr->second->State == PLAYERSPELL_REMOVED)
14297  continue;
14298 
14299  // pussywizard: was => isn't
14300  if (itr->second->IsInSpec(oldSpec) && !itr->second->IsInSpec(spec))
14301  {
14302  SendLearnPacket(itr->first, false);
14303  // We want to remove all auras of the unlearned spell
14304  _removeTalentAurasAndSpells(itr->first);
14305 
14306  removedSpecAuras.insert(itr->first);
14307  }
14308  // pussywizard: wasn't => is
14309  else if (!itr->second->IsInSpec(oldSpec) && itr->second->IsInSpec(spec))
14310  {
14311  SendLearnPacket(itr->first, true);
14312 
14313  removedSpecAuras.erase(itr->first);
14314  }
14315  }
14316 
14317  // xinef: apply glyphs from second spec
14318  if (GetActiveSpec() != oldSpec)
14319  {
14320  for (uint8 slot = 0; slot < MAX_GLYPH_SLOT_INDEX; ++slot)
14321  {
14322  uint32 glyphId = m_Glyphs[GetActiveSpec()][slot];
14323  if (glyphId)
14324  {
14325  if (GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyphId))
14326  {
14328  removedSpecAuras.erase(glyphEntry->SpellId);
14329  }
14330  }
14331 
14332  SetGlyph(slot, glyphId, true);
14333  }
14334  }
14335 
14336  // Remove auras triggered/activated by talents/glyphs
14337  // Mostly explicit casts in dummy aura scripts
14338  if (!removedSpecAuras.empty())
14339  {
14340  for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();)
14341  {
14342  Aura* aura = iter->second;
14343  if (SpellInfo const* triggeredByAuraSpellInfo = aura->GetTriggeredByAuraSpellInfo())
14344  {
14345  if (removedSpecAuras.find(triggeredByAuraSpellInfo->Id) != removedSpecAuras.end())
14346  {
14347  RemoveOwnedAura(iter);
14348  continue;
14349  }
14350  }
14351  ++iter;
14352  }
14353  }
14354 
14355  m_usedTalentCount = spentTalents;
14357 
14358  // load them asynchronously
14359  {
14361  stmt->setUInt32(0, GetGUID().GetCounter());
14362  stmt->setUInt8(1, m_activeSpec);
14363 
14364  WorldSession* mySess = GetSession();
14365  mySess->GetQueryProcessor().AddCallback(CharacterDatabase.AsyncQuery(stmt)
14366  .WithPreparedCallback([mySess](PreparedQueryResult result)
14367  {
14368  // safe callback, we can't pass this pointer directly
14369  // in case player logs out before db response (player would be deleted in that case)
14370  if (Player* thisPlayer = mySess->GetPlayer())
14371  thisPlayer->LoadActions(result);
14372  }));
14373  }
14374 
14375  // xinef: reset power
14376  Powers pw = getPowerType();
14377  if (pw != POWER_MANA)
14378  SetPower(POWER_MANA, 0); // Mana must be 0 even if it isn't the active power type.
14379  SetPower(pw, 0);
14380 
14381  // xinef: remove titan grip if player had it set and does not have appropriate talent
14382  if (!HasTalent(46917, GetActiveSpec()) && m_canTitanGrip)
14383  SetCanTitanGrip(false);
14384  // xinef: remove dual wield if player does not have dual wield spell (shamans)
14385  if (!HasSpell(674) && m_canDualWield)
14386  SetCanDualWield(false);
14387 
14389 
14390  // Xinef: Patch 3.2.0: Switching spec removes paladins spell Righteous Fury (25780)
14391  if (getClass() == CLASS_PALADIN)
14392  RemoveAurasDueToSpell(25780);
14393 
14394  // Xinef: Remove talented single target auras at other targets
14395  AuraList& scAuras = GetSingleCastAuras();
14396  for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
14397  {
14398  Aura* aura = *iter;
14399  if (!HasActiveSpell(aura->GetId()) && !HasTalent(aura->GetId(), GetActiveSpec()))
14400  {
14401  aura->Remove();
14402  iter = scAuras.begin();
14403  }
14404  else
14405  ++iter;
14406  }
14407 }
14408 
14410 {
14411  if (result)
14412  _LoadActions(result);
14413 
14414  SendActionButtons(1);
14415 }
14416 
14417 void Player::GetTalentTreePoints(uint8 (&specPoints)[3]) const
14418 {
14419  const PlayerTalentMap& talentMap = GetTalentMap();
14420  for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
14421  if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(GetActiveSpec()))
14422  if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(itr->second->talentID))
14423  if (TalentTabEntry const* tab = sTalentTabStore.LookupEntry(talentInfo->TalentTab))
14424  if (tab->tabpage < 3)
14425  {
14426  // find current talent rank
14427  uint8 currentTalentRank = 0;
14428  for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
14429  if (talentInfo->RankID[rank] && itr->first == talentInfo->RankID[rank])
14430  {
14431  currentTalentRank = rank + 1;
14432  break;
14433  }
14434  specPoints[tab->tabpage] += currentTalentRank;
14435  }
14436 }
14437 
14439 {
14440  uint32 specPoints[3] = {0, 0, 0};
14441  const PlayerTalentMap& talentMap = GetTalentMap();
14442  for (PlayerTalentMap::const_iterator itr = talentMap.begin(); itr != talentMap.end(); ++itr)
14443  if (itr->second->State != PLAYERSPELL_REMOVED && itr->second->IsInSpec(GetActiveSpec()))
14444  if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(itr->second->talentID))
14445  if (TalentTabEntry const* tab = sTalentTabStore.LookupEntry(talentInfo->TalentTab))
14446  if (tab->tabpage < 3)
14447  {
14448  // find current talent rank
14449  uint8 currentTalentRank = 0;
14450  for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
14451  if (talentInfo->RankID[rank] && itr->first == talentInfo->RankID[rank])
14452  {
14453  currentTalentRank = rank + 1;
14454  break;
14455  }
14456  specPoints[tab->tabpage] += currentTalentRank;
14457  }
14458  uint8 maxIndex = 0;
14459  uint8 maxCount = specPoints[0];
14460  for (uint8 i = 1; i < 3; ++i)
14461  if (specPoints[i] > maxCount)
14462  {
14463  maxIndex = i;
14464  maxCount = specPoints[i];
14465  }
14466  return maxIndex;
14467 }
14468 
14469 void Player::SetReputation(uint32 factionentry, uint32 value)
14470 {
14471  GetReputationMgr().SetReputation(sFactionStore.LookupEntry(factionentry), value);
14472 }
14474 {
14475  return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry));
14476 }
14477 
14478 std::string const& Player::GetGuildName()
14479 {
14480  return sGuildMgr->GetGuildById(GetGuildId())->GetName();
14481 }
14482 
14484 {
14486  data << uint32(counter); // seconds
14487  GetSession()->SendPacket(&data);
14488 }
14489 
14491 {
14492  if (on)
14493  {
14497  //SetFaction(1100);
14501  SetDisplayId(23691);
14502  }
14503  else
14504  {
14506  if (IsSpectator())
14510  RestoreDisplayId();
14511 
14512  if (!IsGameMaster())
14513  {
14514  //SetFactionForRace(getRace());
14515 
14516  // restore FFA PvP Server state
14517  // Xinef: it will be removed if necessery in UpdateArea called in WorldPortOpcode
14518  if (sWorld->IsFFAPvPRealm())
14520  }
14521  }
14522 }
14523 
14525 {
14526  if (FindMap() && FindMap()->IsBattleArena() && !IsSpectator())
14527  {
14528  Battleground* bg = ((BattlegroundMap*)FindMap())->GetBG();
14529  if (bg && bg->HaveSpectators() && bg->GetStatus() == STATUS_IN_PROGRESS && !bg->GetPlayers().empty())
14530  if (bg->GetPlayers().find(GetGUID()) != bg->GetPlayers().end())
14531  return true;
14532  }
14533  return false;
14534 }
14535 
14537 {
14538  for (int i = 0; i < NUM_CAI_SPELLS; ++i)
14539  m_charmAISpells[i] = 0;
14540 
14541  uint32 damage_type[4] = {0, 0, 0, 0};
14542  uint32 periodic_damage = 0;
14543 
14544  for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
14545  {
14546  if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active || !itr->second->IsInSpec(GetActiveSpec()))
14547  continue;
14548 
14549  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
14550  if (!spellInfo)
14551  continue;
14552 
14553  if (!spellInfo->SpellFamilyName || spellInfo->IsPassive() || spellInfo->NeedsComboPoints() || (spellInfo->Stances && !spellInfo->HasAttribute(SPELL_ATTR2_ALLOW_WHILE_NOT_SHAPESHIFTED)))
14554  continue;
14555 
14556  float cast = spellInfo->CalcCastTime() / 1000.0f;
14557  if (cast > 3.0f)
14558  continue;
14559 
14560  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
14561  {
14562  if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
14563  {
14564  int32 dmg = CalculateSpellDamage(this, spellInfo, i);
14565  uint8 offset = 0;
14566  if (cast)
14567  {
14568  dmg = dmg / cast;
14569  offset = 2;
14570  }
14571 
14572  if ((int32)damage_type[offset] < dmg)
14573  {
14574  if (!m_charmAISpells[SPELL_INSTANT_DAMAGE + offset] || !spellInfo->IsHighRankOf(sSpellMgr->GetSpellInfo(m_charmAISpells[SPELL_INSTANT_DAMAGE + offset])) || urand(0, 1))
14575  if (damage_type[1 + offset] < damage_type[offset])
14576  {
14578  damage_type[1 + offset] = damage_type[offset];
14579  }
14580 
14581  m_charmAISpells[SPELL_INSTANT_DAMAGE + offset] = spellInfo->Id;
14582  damage_type[offset] = dmg;
14583  }
14584  else if ((int32)damage_type[1 + offset] < dmg)
14585  {
14586  if (m_charmAISpells[SPELL_INSTANT_DAMAGE + offset] && sSpellMgr->GetSpellInfo(m_charmAISpells[SPELL_INSTANT_DAMAGE + offset])->IsHighRankOf(spellInfo) && urand(0, 1))
14587  continue;
14588 
14589  m_charmAISpells[SPELL_INSTANT_DAMAGE2 + offset] = spellInfo->Id;
14590  damage_type[1 + offset] = dmg;
14591  }
14592  break;
14593  }
14595  {
14596  m_charmAISpells[SPELL_T_CHARGE] = spellInfo->Id;
14597  break;
14598  }
14599  else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_SPEED)
14600  {
14601  m_charmAISpells[SPELL_FAST_RUN] = spellInfo->Id;
14602  break;
14603  }
14604  else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_SCHOOL_IMMUNITY)
14605  {
14606  m_charmAISpells[SPELL_IMMUNITY] = spellInfo->Id;
14607  break;
14608  }
14609  else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE)
14610  {
14611  if( (int32)periodic_damage < CalculateSpellDamage(this, spellInfo, i) )
14612  {
14613  m_charmAISpells[SPELL_DOT_DAMAGE] = spellInfo->Id;
14614  break;
14615  }
14616  }
14617  else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_STUN)
14618  {
14619  m_charmAISpells[SPELL_T_STUN] = spellInfo->Id;
14620  break;
14621  }
14622  else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_ROOT || spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_FEAR)
14623  {
14624  m_charmAISpells[SPELL_ROOT_OR_FEAR] = spellInfo->Id;
14625  break;
14626  }
14627  }
14628  }
14629 }
14630 
14632 {
14633  m_refundableItems.insert(itemGUID);
14634 }
14635 
14637 {
14638  RefundableItemsSet::iterator itr = m_refundableItems.find(itemGUID);
14639  if (itr != m_refundableItems.end())
14640  m_refundableItems.erase(itr);
14641 }
14642 
14644 {
14645  // This function call unsets ITEM_FLAGS_REFUNDABLE if played time is over 2 hours.
14646  item->UpdatePlayedTime(this);
14647 
14649  {
14650  LOG_DEBUG("entities.player.items", "Item refund: item not refundable!");
14651  return;
14652  }
14653 
14654  if (GetGUID().GetCounter() != item->GetRefundRecipient()) // Formerly refundable item got traded
14655  {
14656  LOG_DEBUG("entities.player.items", "Item refund: item was traded!");
14657  item->SetNotRefundable(this);
14658  return;
14659  }
14660 
14661  ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(item->GetPaidExtendedCost());
14662  if (!iece)
14663  {
14664  LOG_DEBUG("entities.player.items", "Item refund: cannot find extendedcost data.");
14665  return;
14666  }
14667 
14668  WorldPacket data(SMSG_ITEM_REFUND_INFO_RESPONSE, 8 + 4 + 4 + 4 + 4 * 4 + 4 * 4 + 4 + 4);
14669  data << item->GetGUID(); // item guid
14670  data << uint32(item->GetPaidMoney()); // money cost
14671  data << uint32(iece->reqhonorpoints); // honor point cost
14672  data << uint32(iece->reqarenapoints); // arena point cost
14673  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
14674  {
14675  data << uint32(iece->reqitem[i]);
14676  data << uint32(iece->reqitemcount[i]);
14677  }
14678  data << uint32(0);
14679  data << uint32(GetTotalPlayedTime() - item->GetPlayedTime());
14680  GetSession()->SendPacket(&data);
14681 }
14682 
14683 bool Player::AddItem(uint32 itemId, uint32 count)
14684 {
14685  uint32 noSpaceForCount = 0;
14686  ItemPosCountVec dest;
14687  InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
14688  if (msg != EQUIP_ERR_OK)
14689  count -= noSpaceForCount;
14690 
14691  if (count == 0 || dest.empty())
14692  {
14693  // -- TODO: Send to mailbox if no space
14694  ChatHandler(GetSession()).PSendSysMessage("You don't have any space in your bags.");
14695  return false;
14696  }
14697 
14698  Item* item = StoreNewItem(dest, itemId, true);
14699  if (item)
14700  SendNewItem(item, count, true, false);
14701  else
14702  return false;
14703  return true;
14704 }
14705 
14707 {
14709  {
14710  LOG_DEBUG("entities.player.items", "Item refund: item not refundable!");
14711  return;
14712  }
14713 
14714  if (item->IsRefundExpired()) // item refund has expired
14715  {
14716  item->SetNotRefundable(this);
14717  WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4);
14718  data << item->GetGUID(); // Guid
14719  data << uint32(10); // Error!
14720  GetSession()->SendPacket(&data);
14721  return;
14722  }
14723 
14724  if (GetGUID().GetCounter() != item->GetRefundRecipient()) // Formerly refundable item got traded
14725  {
14726  LOG_DEBUG("entities.player.items", "Item refund: item was traded!");
14727  item->SetNotRefundable(this);
14728  return;
14729  }
14730 
14731  ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(item->GetPaidExtendedCost());
14732  if (!iece)
14733  {
14734  LOG_DEBUG("entities.player.items", "Item refund: cannot find extendedcost data.");
14735  return;
14736  }
14737 
14738  bool store_error = false;
14739  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
14740  {
14741  uint32 count = iece->reqitemcount[i];
14742  uint32 itemid = iece->reqitem[i];
14743 
14744  if (count && itemid)
14745  {
14746  ItemPosCountVec dest;
14747  InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count);
14748  if (msg != EQUIP_ERR_OK)
14749  {
14750  store_error = true;
14751  break;
14752  }
14753  }
14754  }
14755 
14756  if (store_error)
14757  {
14758  WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4);
14759  data << item->GetGUID(); // Guid
14760  data << uint32(10); // Error!
14761  GetSession()->SendPacket(&data);
14762  return;
14763  }
14764 
14765  WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4 + 4 + 4 + 4 + 4 * 4 + 4 * 4);
14766  data << item->GetGUID(); // item guid
14767  data << uint32(0); // 0, or error code
14768  data << uint32(item->GetPaidMoney()); // money cost
14769  data << uint32(iece->reqhonorpoints); // honor point cost
14770  data << uint32(iece->reqarenapoints); // arena point cost
14771  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
14772  {
14773  data << uint32(iece->reqitem[i]);
14774  data << uint32(iece->reqitemcount[i]);
14775  }
14776  GetSession()->SendPacket(&data);
14777 
14778  uint32 moneyRefund = item->GetPaidMoney(); // item-> will be invalidated in DestroyItem
14779 
14780  // Save all relevant data to DB to prevent desynchronisation exploits
14781  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
14782 
14783  // Delete any references to the refund data
14784  item->SetNotRefundable(this, true, &trans);
14785 
14786  // Destroy item
14787  DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
14788 
14789  // Grant back extendedcost items
14790  for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
14791  {
14792  uint32 count = iece->reqitemcount[i];
14793  uint32 itemid = iece->reqitem[i];
14794  if (count && itemid)
14795  {
14796  ItemPosCountVec dest;
14797  InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count);
14798  ASSERT(msg == EQUIP_ERR_OK);
14799  Item* it = StoreNewItem(dest, itemid, true);
14800  SendNewItem(it, count, true, false, true);
14801  }
14802  }
14803 
14804  // Grant back money
14805  if (moneyRefund)
14806  ModifyMoney(moneyRefund); // Saved in SaveInventoryAndGoldToDB
14807 
14808  // Grant back Honor points
14809  if (uint32 honorRefund = iece->reqhonorpoints)
14810  ModifyHonorPoints(honorRefund, trans);
14811 
14812  // Grant back Arena points
14813  if (uint32 arenaRefund = iece->reqarenapoints)
14814  ModifyArenaPoints(arenaRefund, trans);
14815 
14816  SaveInventoryAndGoldToDB(trans);
14817 
14818  CharacterDatabase.CommitTransaction(trans);
14819 }
14820 
14821 void Player::SetRandomWinner(bool isWinner)
14822 {
14823  m_IsBGRandomWinner = isWinner;
14824  if (m_IsBGRandomWinner)
14825  {
14827  stmt->setUInt32(0, GetGUID().GetCounter());
14828  CharacterDatabase.Execute(stmt);
14829  }
14830 }
14831 
14833 {
14834  if (result)
14835  m_IsBGRandomWinner = true;
14836 }
14837 
14839 {
14840  float sum = 0;
14841  uint32 count = 0;
14842  uint8 level = getLevel();
14843 
14844  for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
14845  {
14846  // don't check tabard, ranged, offhand or shirt
14848  continue;
14849 
14850  if (m_items[i] && m_items[i]->GetTemplate())
14851  sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality(level);
14852 
14853  ++count;
14854  }
14855 
14856  return std::max<float>(0.0f, sum / (float)count);
14857 }
14858 
14860 {
14861  float sum = 0;
14862  uint32 count = 0;
14863  uint8 level = getLevel();
14864 
14865  for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
14866  {
14867  // don't check tabard, ranged, offhand or shirt
14869  continue;
14870 
14871  if (m_items[i] && m_items[i]->GetTemplate())
14872  {
14873  if (m_items[i]->GetTemplate()->Quality == ITEM_QUALITY_HEIRLOOM)
14874  sum += level * 2.33f;
14875  else
14876  sum += m_items[i]->GetTemplate()->ItemLevel;
14877  }
14878 
14879  ++count;
14880  }
14881 
14882  return std::max(0.0f, sum / (float)count);
14883 }
14884 
14886 {
14887  if (!result)
14888  return;
14889 
14890  do
14891  {
14892  Field* fields = result->Fetch();
14893  _instanceResetTimes.insert(InstanceTimeMap::value_type(fields[0].GetUInt32(), fields[1].GetUInt64()));
14894  } while (result->NextRow());
14895 }
14896 
14898 {
14899  uint32 lastEventId = 0;
14900  if (result)
14901  {
14902  Field* fields = result->Fetch();
14903  lastEventId = fields[0].GetUInt32();
14904  }
14905 
14906  time_t curtime = time(nullptr);
14907  tm localTime;
14908  localtime_r(&curtime, &localTime);
14909 
14910  uint16 month = uint16(localTime.tm_mon);
14911  uint16 eventId = month;
14912  if (eventId < 9)
14913  eventId += 3;
14914  else
14915  eventId -= 9;
14916 
14917  // Brew of the Month October (first in list)
14918  eventId += 34;
14919 
14920  if (lastEventId != eventId && IsEventActive(eventId) && HasAchieved(2796 /* Brew of the Month*/))
14921  {
14922  // Send Mail
14923  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
14924  MailSender sender(MAIL_CREATURE, 27487 /*NPC_BREW_OF_THE_MONTH_CLUB*/);
14925  MailDraft draft(uint16(212 + month)); // 212 is starting template id
14926  draft.SendMailTo(trans, MailReceiver(this, GetGUID().GetCounter()), sender);
14927 
14928  // Update Event Id
14930  stmt->setUInt32(0, GetGUID().GetCounter());
14931  stmt->setUInt32(1, uint32(eventId));
14932  trans->Append(stmt);
14933 
14934  CharacterDatabase.CommitTransaction(trans);
14935  }
14936 }
14937 
14939 {
14940  if (_instanceResetTimes.empty())
14941  return;
14942 
14944  stmt->setUInt32(0, GetSession()->GetAccountId());
14945  trans->Append(stmt);
14946 
14947  for (InstanceTimeMap::const_iterator itr = _instanceResetTimes.begin(); itr != _instanceResetTimes.end(); ++itr)
14948  {
14949  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES);
14950  stmt->setUInt32(0, GetSession()->GetAccountId());
14951  stmt->setUInt32(1, itr->first);
14952  stmt->setUInt64(2, itr->second);
14953  trans->Append(stmt);
14954  }
14955 }
14956 
14958 {
14959  for (WhisperListContainer::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr)
14960  if (*itr == guid)
14961  return true;
14962 
14963  return false;
14964 }
14965 
14966 bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/)
14967 {
14968  if (!packetOnly && !Unit::SetDisableGravity(disable))
14969  return false;
14970 
14972  data << GetPackGUID();
14973  data << uint32(0);
14974  SendDirectMessage(&data);
14975 
14977  data << GetPackGUID();
14978  BuildMovementPacket(&data);
14979  SendMessageToSet(&data, false);
14980  return true;
14981 }
14982 
14983 bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
14984 {
14985  sScriptMgr->AnticheatSetCanFlybyServer(this, apply);
14986 
14987  if (!packetOnly && !Unit::SetCanFly(apply))
14988  return false;
14989 
14990  if (!apply)
14991  SetFallInformation(time(nullptr), GetPositionZ());
14992 
14994  data << GetPackGUID();
14995  data << uint32(0);
14996  SendDirectMessage(&data);
14997 
14999  data << GetPackGUID();
15000  BuildMovementPacket(&data);
15001  SendMessageToSet(&data, false);
15002  return true;
15003 }
15004 
15005 bool Player::SetHover(bool apply, bool packetOnly /*= false*/)
15006 {
15007  if (!packetOnly && !Unit::SetHover(apply))
15008  return false;
15009 
15011  data << GetPackGUID();
15012  data << uint32(0);
15013  SendDirectMessage(&data);
15014 
15015  data.Initialize(MSG_MOVE_HOVER, 64);
15016  data << GetPackGUID();
15017  BuildMovementPacket(&data);
15018  SendMessageToSet(&data, false);
15019  return true;
15020 }
15021 
15022 bool Player::SetWaterWalking(bool apply, bool packetOnly /*= false*/)
15023 {
15024  if (!packetOnly && !Unit::SetWaterWalking(apply))
15025  return false;
15026 
15028  data << GetPackGUID();
15029  data << uint32(0);
15030  SendDirectMessage(&data);
15031 
15032  data.Initialize(MSG_MOVE_WATER_WALK, 64);
15033  data << GetPackGUID();
15034  BuildMovementPacket(&data);
15035  SendMessageToSet(&data, false);
15036  return true;
15037 }
15038 
15039 bool Player::SetFeatherFall(bool apply, bool packetOnly /*= false*/)
15040 {
15041  // Xinef: moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed
15042  if (!packetOnly/* && !Unit::SetFeatherFall(apply)*/)
15043  {
15045  //return false;
15046  }
15047 
15049  data << GetPackGUID();
15050  data << uint32(0);
15051  SendDirectMessage(&data);
15052 
15054  data << GetPackGUID();
15055  BuildMovementPacket(&data);
15056  SendMessageToSet(&data, false);
15057  return true;
15058 }
15059 
15061 {
15062  // Sanity check for active camera set
15063  if (m_activeCinematicCameraId == 0)
15064  {
15065  return;
15066  }
15067 
15069  if (itr != sFlyByCameraStore.end())
15070  {
15071  // Initialize diff, and set camera
15072  m_cinematicDiff = 0;
15073  m_cinematicCamera = &itr->second;
15074 
15075  auto camitr = m_cinematicCamera->begin();
15076  if (camitr != m_cinematicCamera->end())
15077  {
15078  Position pos(camitr->locations.x, camitr->locations.y, camitr->locations.z, camitr->locations.w);
15079  if (!pos.IsPositionValid())
15080  {
15081  return;
15082  }
15083 
15084  m_mapRef->LoadGrid(camitr->locations.x, camitr->locations.y);
15086  if (m_CinematicObject)
15087  {
15090  }
15091  }
15092  }
15093 }
15094 
15096 {
15097  m_cinematicDiff = 0;
15098  m_cinematicCamera = nullptr;
15100  if (m_CinematicObject)
15101  {
15102  if (m_seer && m_seer == m_CinematicObject)
15103  {
15105  }
15107  }
15108 }
15109 
15111 {
15112  uint32 guildId = GetGuildId();
15113  return guildId ? sGuildMgr->GetGuildById(guildId) : nullptr;
15114 }
15115 
15116 void Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration, uint32 createdBySpell, ObjectGuid casterGUID, uint8 asynchLoadType)
15117 {
15118  Position pos = {x, y, z, ang};
15119  if (!pos.IsPositionValid())
15120  return;
15121 
15122  AsynchPetSummon* asynchPetInfo = new AsynchPetSummon(entry, pos, petType, duration, createdBySpell, casterGUID);
15123  Pet::LoadPetFromDB(this, asynchLoadType, entry, 0, false, asynchPetInfo);
15124 }
15125 
15127 {
15128  /*
15129  * Check PET_SAVE_NOT_IN_SLOT means the pet is dismissed. If someone ever
15130  * Changes the slot flag, they will break this validation.
15131  */
15133  stmt->setUInt32(0, GetGUID().GetCounter());
15134  stmt->setUInt8(1, uint8(PET_SAVE_NOT_IN_SLOT));
15135 
15136  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
15137  return true;
15138 
15139  return false;
15140 }
15141 
15143 {
15144  uint32 mostTalentTabId = 0;
15145  uint32 mostTalentCount = 0;
15146  uint32 specIdx = 0;
15147 
15148  if (m_specsCount) // not all instances of Player have a spec for some reason
15149  {
15150  if (spec < 0)
15151  specIdx = m_activeSpec;
15152  else
15153  specIdx = spec;
15154  // find class talent tabs (all players have 3 talent tabs)
15155  uint32 const* talentTabIds = GetTalentTabPages(getClass());
15156 
15157  for (uint8 i = 0; i < MAX_TALENT_TABS; ++i)
15158  {
15159  uint32 talentCount = 0;
15160  uint32 talentTabId = talentTabIds[i];
15161  for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
15162  {
15163  TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
15164  if (!talentInfo)
15165  continue;
15166 
15167  // skip another tab talents
15168  if (talentInfo->TalentTab != talentTabId)
15169  continue;
15170 
15171  // find max talent rank (0~4)
15172  int8 curtalent_maxrank = -1;
15173  for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
15174  {
15175  if (talentInfo->RankID[rank] && HasTalent(talentInfo->RankID[rank], specIdx))
15176  {
15177  curtalent_maxrank = rank;
15178  break;
15179  }
15180  }
15181 
15182  // not learned talent
15183  if (curtalent_maxrank < 0)
15184  continue;
15185 
15186  talentCount += curtalent_maxrank + 1;
15187  }
15188 
15189  if (mostTalentCount < talentCount)
15190  {
15191  mostTalentCount = talentCount;
15192  mostTalentTabId = talentTabId;
15193  }
15194  }
15195  }
15196  return mostTalentTabId;
15197 }
15198 
15200 {
15201  switch (GetSpec())
15202  {
15206  return true;
15209  return true;
15210  break;
15211  default:
15212  break;
15213  }
15214  return false;
15215 }
15216 
15218 {
15219  switch (GetSpec(GetActiveSpec()))
15220  {
15230  return true;
15232  if (GetShapeshiftForm() == FORM_CAT)
15233  return true;
15234  default:
15235  break;
15236  }
15237  return false;
15238 }
15239 
15241 {
15242  switch (GetSpec(GetActiveSpec()))
15243  {
15247  case TALENT_TREE_MAGE_FIRE:
15256  return true;
15257  default:
15258  break;
15259  }
15260  return false;
15261 }
15262 
15264 {
15265  switch (GetSpec(GetActiveSpec()))
15266  {
15272  return true;
15273  default:
15274  break;
15275  }
15276  return false;
15277 }
15278 
15279 std::unordered_map<int, bgZoneRef> Player::bgZoneIdToFillWorldStates = {};
15280 
15281 void Player::SetRestFlag(RestFlag restFlag, uint32 triggerId /*= 0*/)
15282 {
15283  uint32 oldRestMask = _restFlagMask;
15284  _restFlagMask |= restFlag;
15285 
15286  if (!oldRestMask && _restFlagMask) // only set flag/time on the first rest state
15287  {
15288  _restTime = time(nullptr);
15290  }
15291 
15292  if (triggerId)
15293  _innTriggerId = triggerId;
15294 }
15295 
15297 {
15298  uint32 oldRestMask = _restFlagMask;
15299  _restFlagMask &= ~restFlag;
15300 
15301  if (oldRestMask && !_restFlagMask) // only remove flag/time on the last rest state remove
15302  {
15303  _restTime = 0;
15305  }
15306 }
15307 
15309 {
15310  if (sScriptMgr->NotSetArenaTeamInfoField(this, slot, type, value))
15312 }
15313 
15315 {
15317 
15318  sScriptMgr->OnGetArenaPersonalRating(const_cast<Player*>(this), slot, result);
15319 
15320  return result;
15321 }
15322 
15324 {
15326 
15327  sScriptMgr->OnGetArenaTeamId(const_cast<Player*>(this), slot, result);
15328 
15329  return result;
15330 }
15331 
15333 {
15334  bool result = Unit::IsFFAPvP();
15335 
15336  sScriptMgr->OnIsFFAPvP(this, result);
15337 
15338  return result;
15339 }
15340 
15342 {
15343  bool result = Unit::IsPvP();
15344 
15345  sScriptMgr->OnIsPvP(this, result);
15346 
15347  return result;
15348 }
15349 
15351 {
15353 
15354  sScriptMgr->OnGetMaxSkillValueForLevel(const_cast<Player*>(this), result);
15355 
15356  return result;
15357 }
15358 
15360 {
15361  float result = sWorld->getRate(RATE_XP_QUEST);
15362 
15363  sScriptMgr->OnGetQuestRate(this, result);
15364 
15365  return result;
15366 }
15367 
15369 {
15370  sScriptMgr->OnSetServerSideVisibility(this, type, sec);
15371 
15372  m_serverSideVisibility.SetValue(type, sec);
15373 }
15374 
15376 {
15377  sScriptMgr->OnSetServerSideVisibilityDetect(this, type, sec);
15378 
15380 }
15381 
15383 {
15384  _farSightDistance = radius;
15385 }
15386 
15388 {
15389  _farSightDistance.reset();
15390 }
15391 
15393 {
15394  return _farSightDistance;
15395 }
15396 
15397 float Player::GetSightRange(const WorldObject* target) const
15398 {
15399  float sightRange = WorldObject::GetSightRange(target);
15400  if (_farSightDistance)
15401  {
15402  sightRange += *_farSightDistance;
15403  }
15404 
15405  return sightRange;
15406 }
15407 
15409 {
15410  std::string name = GetName();
15411  std::string color = "";
15412 
15413  switch (getClass())
15414  {
15415  case CLASS_DEATH_KNIGHT: color = "|cffC41F3B"; break;
15416  case CLASS_DRUID: color = "|cffFF7D0A"; break;
15417  case CLASS_HUNTER: color = "|cffABD473"; break;
15418  case CLASS_MAGE: color = "|cff69CCF0"; break;
15419  case CLASS_PALADIN: color = "|cffF58CBA"; break;
15420  case CLASS_PRIEST: color = "|cffFFFFFF"; break;
15421  case CLASS_ROGUE: color = "|cffFFF569"; break;
15422  case CLASS_SHAMAN: color = "|cff0070DE"; break;
15423  case CLASS_WARLOCK: color = "|cff9482C9"; break;
15424  case CLASS_WARRIOR: color = "|cffC79C6E"; break;
15425  }
15426 
15427  return "|Hplayer:" + name + "|h" + color + name + "|h|r";
15428 }
#define SPECTATOR_SPELL_SPEED
#define SPECTATOR_COOLDOWN_MAX
#define SPECTATOR_COOLDOWN_MIN
ArenaTeamInfoType
Definition: ArenaTeam.h:74
@ ARENA_TEAM_ID
Definition: ArenaTeam.h:75
@ ARENA_TEAM_END
Definition: ArenaTeam.h:82
@ ARENA_TEAM_PERSONAL_RATING
Definition: ArenaTeam.h:81
#define MAX_ARENA_SLOT
Definition: ArenaTeam.h:135
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define MAX_BAG_SIZE
Definition: Bag.h:22
@ BATTLEFIELD_WG
Definition: Battlefield.h:31
@ BATTLEFIELD_BATTLEID_WG
Definition: Battlefield.h:37
#define sBattlefieldMgr
@ AREA_WINTERGRASP
const uint32 ClockWorldState[2]
Definition: BattlefieldWG.h:42
@ BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE
@ BATTLEFIELD_WG_WORLD_STATE_ACTIVE
@ BATTLEFIELD_WG_WORLD_STATE_DEFENDER
@ BATTLEFIELD_WG_WORLD_STATE_ATTACKER
@ BG_DESERTION_TYPE_LEAVE_BG
Definition: Battleground.h:49
@ SPELL_AURA_PLAYER_INACTIVE
Definition: Battleground.h:121
@ SPELL_RECENTLY_DROPPED_FLAG
Definition: Battleground.h:120
@ SCORE_BONUS_HONOR
Definition: Battleground.h:202
@ STATUS_WAIT_JOIN
Definition: Battleground.h:178
@ STATUS_IN_PROGRESS
Definition: Battleground.h:179
@ BG_AV_OBJECTID_MINE_N
@ BG_AV_OBJECTID_MINE_S
#define sBattlegroundMgr
npc
@ CHANNEL_DBC_FLAG_CITY_ONLY
Definition: Channel.h:100
@ CHANNEL_DBC_FLAG_GUILD_REQ
Definition: Channel.h:103
@ CHANNEL_DBC_FLAG_ZONE_DEP
Definition: Channel.h:97
@ CHANNEL_DBC_FLAG_LFG
Definition: Channel.h:104
@ CHAR_DEL_CHAR_GLYPHS
@ CHAR_DEL_QUEST_STATUS_DAILY_CHAR
@ CHAR_DEL_CHAR_SOCIAL_BY_FRIEND
@ CHAR_DEL_CHAR_GIFT
@ CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER
@ CHAR_SEL_CHAR_OLD_CHARS
@ CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER
@ CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_SYNS
@ CHAR_UPD_REM_AT_LOGIN_FLAG
@ CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER
@ CHAR_UPD_EQUIP_SET
@ CHAR_DEL_CHAR_SKILLS
@ CHAR_DEL_CHAR_PET_BY_OWNER
@ CHAR_SEL_CHAR_PETS
@ CHAR_DEL_QUEST_STATUS_WEEKLY_CHAR
@ CHAR_INS_CHAR_TALENT
@ CHAR_DEL_ITEM_INSTANCE_BY_OWNER
@ CHAR_DEL_PETITION_SIGNATURE
@ CHAR_DEL_CHAR_DECLINED_NAME
@ CHAR_DEL_PETITION_SIGNATURE_BY_OWNER
@ CHAR_INS_EQUIP_SET
@ CHAR_DEL_ALL_PETITION_SIGNATURES
@ CHAR_INS_BATTLEGROUND_RANDOM
@ CHAR_SEL_MAILITEMS
@ CHAR_UPD_DELETE_INFO
@ CHAR_INS_PLAYER_ENTRY_POINT
@ CHAR_DEL_CHARACTER_SKILL
@ CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID
@ CHAR_DEL_PLAYER_HOMEBIND
@ CHAR_DEL_CHAR_EQUIPMENTSETS
@ CHAR_SEL_CHARACTER_ACTIONS_SPEC
@ CHAR_DEL_EQUIP_SET
@ CHAR_DEL_PETITION_SIGNATURE_BY_OWNER_AND_TYPE
@ CHAR_REP_BREW_OF_THE_MONTH
@ CHAR_UDP_CHAR_ARENA_POINTS
@ CHAR_DEL_PLAYER_ACCOUNT_DATA
@ CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR
@ CHAR_DEL_MAIL
@ CHAR_INS_CHAR_GLYPHS
@ CHAR_SEL_CHAR_POSITION_XYZ
@ CHAR_DEL_CHAR_TALENT
@ CHAR_SEL_CHAR_SOCIAL
@ CHAR_UDP_CHAR_HONOR_POINTS
@ CHAR_DEL_CHAR_INVENTORY
@ CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES
@ CHAR_DEL_QUEST_STATUS_MONTHLY_CHAR
@ CHAR_DEL_CHAR_AURA
@ CHAR_INS_CHARACTER
@ CHAR_DEL_CHAR_QUESTSTATUS
@ CHAR_DEL_CHAR_ACTION
@ CHAR_DEL_PLAYER_ENTRY_POINT
@ CHAR_DEL_MAIL_BY_ID
@ CHAR_DEL_CHAR_ACHIEVEMENTS
@ CHAR_UPD_ZONE
@ CHAR_SEL_CHAR_COD_ITEM_MAIL
@ CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
@ CHAR_DEL_CHAR_REPUTATION
@ CHAR_UPD_CHARACTER
@ CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS
@ CHAR_DEL_CHARACTER
@ CHAR_DEL_CHAR_SPELL_COOLDOWN
@ CHAR_DEL_CHAR_TALENT_BY_SPELL
@ CHAR_DEL_CHAR_SOCIAL_BY_GUID
@ CHAR_UPD_CHAR_REMOVE_GHOST
@ CHAR_SEL_CHAR_ZONE
@ CHAR_DEL_MAIL_ITEM_BY_ID
@ CHAR_INS_DESERTER_TRACK
@ CHAR_DEL_CHAR_SPELL
@ CHAR_DEL_CHAR_QUESTSTATUS_REWARDED
@ CHAR_DEL_PETITION_BY_OWNER
@ CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES
@ CHAR_DEL_PLAYER_GM_TICKETS
@ CHAR_DEL_PETITION_BY_OWNER_AND_TYPE
@ CHAR_DEL_MAIL_ITEMS
@ CHAR_DEL_CHAR_INSTANCE
@ CHAR_SEL_PLAYER_ARENA_TEAMS
constexpr auto DAY
Definition: Common.h:58
LocaleConstant
Definition: Common.h:74
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
AccountTypes
Definition: Common.h:65
@ SEC_PLAYER
Definition: Common.h:66
constexpr auto MONTH
Definition: Common.h:60
constexpr auto MINUTE
Definition: Common.h:56
#define sConditionMgr
Definition: ConditionMgr.h:286
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:233
@ CORPSE_RESURRECTABLE_PVE
Definition: Corpse.h:29
@ CORPSE_RESURRECTABLE_PVP
Definition: Corpse.h:30
@ CORPSE_BONES
Definition: Corpse.h:28
@ CORPSE_FLAG_HIDE_CLOAK
Definition: Corpse.h:44
@ CORPSE_FLAG_UNK2
Definition: Corpse.h:42
@ CORPSE_FLAG_HIDE_HELM
Definition: Corpse.h:43
@ CORPSE_FLAG_LOOTABLE
Definition: Corpse.h:45
@ CREATURE_FLAG_EXTRA_NO_XP
Definition: CreatureData.h:52
AchievementCriteriaTimedTypes
Definition: DBCEnums.h:98
@ SKILL_FLAG_ALWAYS_MAX_VALUE
Definition: DBCEnums.h:374
@ ITEM_ENCHANTMENT_TYPE_USE_SPELL
Definition: DBCEnums.h:361
@ ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL
Definition: DBCEnums.h:355
Difficulty
Definition: DBCEnums.h:254
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition: DBCEnums.h:261
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:257
AchievementCriteriaCondition
Definition: DBCEnums.h:75
@ ACHIEVEMENT_CRITERIA_CONDITION_NO_DEATH
Definition: DBCEnums.h:77
@ SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE
Definition: DBCEnums.h:348
@ SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN
Definition: DBCEnums.h:349
@ ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN
Definition: DBCEnums.h:204
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL
Definition: DBCEnums.h:114
@ ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING
Definition: DBCEnums.h:128
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP
Definition: DBCEnums.h:122
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL
Definition: DBCEnums.h:137
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS
Definition: DBCEnums.h:174
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition: DBCEnums.h:113
@ ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL
Definition: DBCEnums.h:208
@ ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM
Definition: DBCEnums.h:129
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING
Definition: DBCEnums.h:165
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL
Definition: DBCEnums.h:138
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE
Definition: DBCEnums.h:207
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS
Definition: DBCEnums.h:162
@ ACHIEVEMENT_CRITERIA_TYPE_HK_RACE
Definition: DBCEnums.h:156
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH
Definition: DBCEnums.h:123
@ ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA
Definition: DBCEnums.h:146
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL
Definition: DBCEnums.h:143
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON
Definition: DBCEnums.h:124
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL
Definition: DBCEnums.h:175
@ ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS
Definition: DBCEnums.h:209
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA
Definition: DBCEnums.h:134
@ ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL
Definition: DBCEnums.h:171
@ ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS
Definition: DBCEnums.h:163
@ ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL
Definition: DBCEnums.h:176
@ AREA_FLAG_ARENA_INSTANCE
Definition: DBCEnums.h:238
@ AREA_FLAG_SLAVE_CAPITAL
Definition: DBCEnums.h:225
@ AREA_FLAG_NEED_FLY
Definition: DBCEnums.h:234
#define DEFAULT_MAX_LEVEL
Definition: DBCEnums.h:24
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
DBCStorage< TalentTabEntry > sTalentTabStore(TalentTabEntryfmt)
DBCStorage< GtRegenMPPerSptEntry > sGtRegenMPPerSptStore(GtRegenMPPerSptfmt)
DBCStorage< TaxiPathEntry > sTaxiPathStore(TaxiPathEntryfmt)
uint32 const * GetTalentTabPages(uint8 cls)
Definition: DBCStores.cpp:1065
DBCStorage< GtChanceToMeleeCritBaseEntry > sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesEntryfmt)
DBCStorage< ScalingStatValuesEntry > sScalingStatValuesStore(ScalingStatValuesfmt)
DBCStorage< ItemExtendedCostEntry > sItemExtendedCostStore(ItemExtendedCostEntryfmt)
SpellCategoryStore sSpellsByCategoryStore
Definition: DBCStores.cpp:146
DBCStorage< GlyphSlotEntry > sGlyphSlotStore(GlyphSlotfmt)
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition: DBCStores.cpp:1117
DBCStorage< SpellItemEnchantmentConditionEntry > sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt)
DBCStorage< CurrencyTypesEntry > sCurrencyTypesStore(CurrencyTypesfmt)
std::unordered_map< uint32, FlyByCameraCollection > sFlyByCameraStore
Definition: DBCStores.cpp:193
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DBCStores.cpp:180
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
uint32 GetTalentSpellCost(uint32 spellId)
Definition: DBCStores.cpp:927
DBCStorage< CinematicSequencesEntry > sCinematicSequencesStore(CinematicSequencesEntryfmt)
DBCStorage< DurabilityCostsEntry > sDurabilityCostsStore(DurabilityCostsfmt)
DBCStorage< GtRegenHPPerSptEntry > sGtRegenHPPerSptStore(GtRegenHPPerSptfmt)
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< SpellShapeshiftEntry > sSpellShapeshiftStore(SpellShapeshiftfmt)
uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
Definition: DBCStores.cpp:944
DBCStorage< QuestFactionRewEntry > sQuestFactionRewardStore(QuestFactionRewardfmt)
DBCStorage< ItemLimitCategoryEntry > sItemLimitCategoryStore(ItemLimitCategoryEntryfmt)
DBCStorage< CreatureFamilyEntry > sCreatureFamilyStore(CreatureFamilyfmt)
DBCStorage< GtChanceToSpellCritBaseEntry > sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt)
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
TalentSpellPos const * GetTalentSpellPos(uint32 spellId)
Definition: DBCStores.cpp:918
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
DBCStorage< GtBarberShopCostBaseEntry > sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt)
DBCStorage< DurabilityQualityEntry > sDurabilityQualityStore(DurabilityQualityfmt)
DBCStorage< GtCombatRatingsEntry > sGtCombatRatingsStore(GtCombatRatingsfmt)
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
DBCStorage< SkillTiersEntry > sSkillTiersStore(SkillTiersfmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
DBCStorage< SkillLineAbilityEntry > sSkillLineAbilityStore(SkillLineAbilityfmt)
DBCStorage< GtChanceToMeleeCritEntry > sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt)
DBCStorage< GtChanceToSpellCritEntry > sGtChanceToSpellCritStore(GtChanceToSpellCritfmt)
CharStartOutfitEntry const * GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender)
Definition: DBCStores.cpp:1083
DBCStorage< ScalingStatDistributionEntry > sScalingStatDistributionStore(ScalingStatDistributionfmt)
LFGDungeonEntry const * GetLFGDungeon(uint32 mapId, Difficulty difficulty)
Returns LFGDungeonEntry for a specific map and difficulty. Will return first found entry if multiple ...
Definition: DBCStores.cpp:1093
DBCStorage< GtOCTClassCombatRatingScalarEntry > sGtOCTClassCombatRatingScalarStore(GtOCTClassCombatRatingScalarfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
DBCStorage< GtOCTRegenHPEntry > sGtOCTRegenHPStore(GtOCTRegenHPfmt)
#define MAX_TALENT_TABS
#define MAX_ITEM_EXTENDED_COST_REQUIREMENTS
std::vector< TaxiPathNodeEntry const * > TaxiPathNodeList
#define MAX_SPELL_REAGENTS
#define GT_MAX_LEVEL
Definition: DBCStructure.h:990
#define MAX_TALENT_RANK
#define MAX_PET_TALENT_RANK
#define GT_MAX_RATING
Definition: DBCStructure.h:993
#define MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS
#define MAX_SPELL_EFFECTS
#define MAX_OUTFIT_ITEMS
Definition: DBCStructure.h:616
#define MAX_SKILL_STEP
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
std::int32_t int32
Definition: Define.h:110
#define UI64FMTD
Definition: Define.h:98
std::uint8_t uint8
Definition: Define.h:116
std::uint32_t uint32
Definition: Define.h:114
std::int8_t int8
Definition: Define.h:112
std::uint64_t uint64
Definition: Define.h:113
std::uint16_t uint16
Definition: Define.h:115
std::int16_t int16
Definition: Define.h:111
@ DISABLE_TYPE_MAP
Definition: DisableMgr.h:31
#define ABORT
Definition: Errors.h:62
#define ASSERT
Definition: Errors.h:58
bool IsEventActive(uint16 event_id)
#define sGraveyard
Definition: GameGraveyard.h:75
@ GO_ACTIVATED
Definition: GameObject.h:733
@ GO_READY
Definition: GameObject.h:732
@ GROUP_UPDATE_FLAG_NONE
Definition: Group.h:97
@ GROUP_UPDATE_PET
Definition: Group.h:118
#define sGroupMgr
Definition: GroupMgr.h:51
@ GUILD_MEMBER_DATA_LEVEL
Definition: Guild.h:46
#define sGuildMgr
Definition: GuildMgr.h:51
@ CONFIG_ARENA_SEASON_ID
Definition: IWorld.h:307
@ CONFIG_BATTLEGROUND_REPORT_AFK_TIMER
Definition: IWorld.h:294
@ CONFIG_CHARDELETE_METHOD
Definition: IWorld.h:333
@ CONFIG_LFG_KICK_PREVENTION_TIMER
Definition: IWorld.h:395
@ CONFIG_MAX_HONOR_POINTS
Definition: IWorld.h:227
@ CONFIG_PVP_TOKEN_MAP_TYPE
Definition: IWorld.h:312
@ CONFIG_CHARDELETE_MIN_LEVEL
Definition: IWorld.h:334
@ CONFIG_MAX_ARENA_POINTS
Definition: IWorld.h:229
@ CONFIG_GAME_TYPE
Definition: IWorld.h:205
@ CONFIG_START_GM_LEVEL
Definition: IWorld.h:245
@ CONFIG_START_HEROIC_PLAYER_LEVEL
Definition: IWorld.h:225
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:222
@ CONFIG_START_ARENA_POINTS
Definition: IWorld.h:230
@ CONFIG_DEATH_SICKNESS_LEVEL
Definition: IWorld.h:287
@ CONFIG_PVP_TOKEN_ID
Definition: IWorld.h:313
@ CONFIG_PVP_TOKEN_COUNT
Definition: IWorld.h:314
@ CONFIG_INSTANT_TAXI
Definition: IWorld.h:361
@ CONFIG_START_PLAYER_MONEY
Definition: IWorld.h:226
@ CONFIG_START_PLAYER_LEVEL
Definition: IWorld.h:224
@ CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL
Definition: IWorld.h:231
@ CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE
Definition: IWorld.h:232
@ CONFIG_INTERVAL_SAVE
Definition: IWorld.h:201
@ CONFIG_GROUP_VISIBILITY
Definition: IWorld.h:246
@ CONFIG_CHARDELETE_KEEP_DAYS
Definition: IWorld.h:332
@ CONFIG_START_HONOR_POINTS
Definition: IWorld.h:228
@ CONFIG_DISABLE_BREATHING
Definition: IWorld.h:289
@ CONFIG_BATTLEGROUND_REPORT_AFK
Definition: IWorld.h:295
@ CONFIG_HONOR_AFTER_DUEL
Definition: IWorld.h:311
@ CONFIG_MAX_PRIMARY_TRADE_SKILL
Definition: IWorld.h:236
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT
Definition: IWorld.h:78
@ CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP
Definition: IWorld.h:107
@ CONFIG_START_ALL_SPELLS
Definition: IWorld.h:129
@ CONFIG_DECLINED_NAMES_USED
Definition: IWorld.h:112
@ CONFIG_LFG_LOCATION_ALL
Definition: IWorld.h:160
@ CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE
Definition: IWorld.h:108
@ CONFIG_PVP_TOKEN_ENABLE
Definition: IWorld.h:133
@ CONFIG_ARENA_SEASON_IN_PROGRESS
Definition: IWorld.h:123
@ CONFIG_NO_RESET_TALENT_COST
Definition: IWorld.h:134
@ CONFIG_WINTERGRASP_ENABLE
Definition: IWorld.h:142
@ CONFIG_BATTLEGROUND_TRACK_DESERTERS
Definition: IWorld.h:120
@ CONFIG_VMAP_INDOOR_CHECK
Definition: IWorld.h:127
@ CONFIG_DELETE_CHARACTER_TICKET_TRACE
Definition: IWorld.h:140
@ CONFIG_ALWAYS_MAXSKILL
Definition: IWorld.h:132
@ CONFIG_START_ALL_EXPLORED
Definition: IWorld.h:130
@ RATE_DAMAGE_FALL
Definition: IWorld.h:469
@ RATE_POWER_RAGE_LOSS
Definition: IWorld.h:405
@ RATE_REPUTATION_LOWLEVEL_QUEST
Definition: IWorld.h:448
@ RATE_REPUTATION_LOWLEVEL_KILL
Definition: IWorld.h:447
@ RATE_POWER_RUNICPOWER_LOSS
Definition: IWorld.h:407
@ RATE_POWER_ENERGY
Definition: IWorld.h:409
@ RATE_TALENT
Definition: IWorld.h:475
@ RATE_POWER_MANA
Definition: IWorld.h:403
@ RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS
Definition: IWorld.h:449
@ RATE_REPAIRCOST
Definition: IWorld.h:445
@ RATE_DROP_MONEY
Definition: IWorld.h:437
@ RATE_HEALTH
Definition: IWorld.h:402
@ RATE_XP_QUEST
Definition: IWorld.h:441
@ RATE_XP_EXPLORE
Definition: IWorld.h:442
@ RATE_HONOR
Definition: IWorld.h:473
@ CONFIG_GROUP_XP_DISTANCE
Definition: IWorld.h:179
@ CONFIG_LISTEN_RANGE_YELL
Definition: IWorld.h:184
@ CONFIG_LISTEN_RANGE_SAY
Definition: IWorld.h:182
@ CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE
Definition: IWorld.h:180
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
Definition: IWorld.h:183
#define sInstanceSaveMgr
void AddItemsSetItem(Player *player, Item *item)
Definition: Item.cpp:30
void RemoveItemsSetItem(Player *player, ItemTemplate const *proto)
Definition: Item.cpp:116
@ BUY_ERR_CANT_FIND_ITEM
Definition: Item.h:135
@ BUY_ERR_DISTANCE_TOO_FAR
Definition: Item.h:139
@ BUY_ERR_NOT_ENOUGHT_MONEY
Definition: Item.h:137
@ BUY_ERR_REPUTATION_REQUIRE
Definition: Item.h:143
@ BUY_ERR_ITEM_ALREADY_SOLD
Definition: Item.h:136
#define MAX_ITEM_SPELLS
Definition: Item.h:209
EnchantmentSlot
Definition: Item.h:162
@ PERM_ENCHANTMENT_SLOT
Definition: Item.h:163
@ MAX_ENCHANTMENT_SLOT
Definition: Item.h:177
@ TEMP_ENCHANTMENT_SLOT
Definition: Item.h:164
@ PRISMATIC_ENCHANTMENT_SLOT
Definition: Item.h:169
@ SOCK_ENCHANTMENT_SLOT
Definition: Item.h:165
@ BONUS_ENCHANTMENT_SLOT
Definition: Item.h:168
InventoryResult
Definition: Item.h:40
@ EQUIP_ERR_CANT_EQUIP_RANK
Definition: Item.h:104
@ EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED
Definition: Item.h:129
@ EQUIP_ERR_TOO_MUCH_GOLD
Definition: Item.h:117
@ EQUIP_ERR_ALREADY_LOOTED
Definition: Item.h:90
@ EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE
Definition: Item.h:108
@ EQUIP_ERR_ITEM_MAX_COUNT_EQUIPPED_SOCKETED
Definition: Item.h:115
@ EQUIP_ERR_ITEM_CANT_BE_EQUIPPED
Definition: Item.h:61
@ EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS
Definition: Item.h:110
@ EQUIP_ERR_OK
Definition: Item.h:41
@ EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT
Definition: Item.h:44
@ EQUIP_ERR_VENDOR_MISSING_TURNINS
Definition: Item.h:109
@ EQUIP_ERR_NONE
Definition: Item.h:100
@ EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS
Definition: Item.h:111
@ ITEM_CHANGED
Definition: Item.h:204
@ ITEM_SUBCLASS_WEAPON_CROSSBOW
Definition: ItemTemplate.h:371
@ ITEM_SUBCLASS_WEAPON_GUN
Definition: ItemTemplate.h:356
@ ITEM_SUBCLASS_WEAPON_BOW
Definition: ItemTemplate.h:355
@ INVTYPE_RANGED
Definition: ItemTemplate.h:280
@ INVTYPE_THROWN
Definition: ItemTemplate.h:290
@ INVTYPE_RANGEDRIGHT
Definition: ItemTemplate.h:291
@ INVTYPE_WEAPON
Definition: ItemTemplate.h:278
@ INVTYPE_WEAPONOFFHAND
Definition: ItemTemplate.h:287
@ INVTYPE_2HWEAPON
Definition: ItemTemplate.h:282
@ ITEM_FIELD_FLAG_REFUNDABLE
Definition: ItemTemplate.h:122
@ ITEM_SPELLTRIGGER_ON_USE
Definition: ItemTemplate.h:78
@ ITEM_SPELLTRIGGER_CHANCE_ON_HIT
Definition: ItemTemplate.h:80
@ ITEM_SPELLTRIGGER_ON_EQUIP
Definition: ItemTemplate.h:79
@ ITEM_FLAG_NO_EQUIP_COOLDOWN
Definition: ItemTemplate.h:155
@ ITEM_FLAG_UNIQUE_EQUIPPABLE
Definition: ItemTemplate.h:167
@ ITEM_FLAG_ITEM_PURCHASE_RECORD
Definition: ItemTemplate.h:160
@ ITEM_MOD_CRIT_TAKEN_RANGED_RATING
Definition: ItemTemplate.h:49
@ ITEM_MOD_HIT_MELEE_RATING
Definition: ItemTemplate.h:39
@ ITEM_MOD_HIT_TAKEN_MELEE_RATING
Definition: ItemTemplate.h:45
@ ITEM_MOD_STAMINA
Definition: ItemTemplate.h:34
@ ITEM_MOD_HIT_SPELL_RATING
Definition: ItemTemplate.h:41
@ ITEM_MOD_SPELL_PENETRATION
Definition: ItemTemplate.h:70
@ ITEM_MOD_PARRY_RATING
Definition: ItemTemplate.h:37
@ ITEM_MOD_DEFENSE_SKILL_RATING
Definition: ItemTemplate.h:35
@ ITEM_MOD_HASTE_RANGED_RATING
Definition: ItemTemplate.h:52
@ ITEM_MOD_CRIT_TAKEN_RATING
Definition: ItemTemplate.h:57
@ ITEM_MOD_EXPERTISE_RATING
Definition: ItemTemplate.h:60
@ ITEM_MOD_MANA
Definition: ItemTemplate.h:28
@ ITEM_MOD_RANGED_ATTACK_POWER
Definition: ItemTemplate.h:62
@ ITEM_MOD_HEALTH
Definition: ItemTemplate.h:29
@ ITEM_MOD_CRIT_TAKEN_SPELL_RATING
Definition: ItemTemplate.h:50
@ ITEM_MOD_HIT_TAKEN_SPELL_RATING
Definition: ItemTemplate.h:47
@ ITEM_MOD_SPIRIT
Definition: ItemTemplate.h:33
@ ITEM_MOD_SPELL_POWER
Definition: ItemTemplate.h:68
@ ITEM_MOD_HASTE_SPELL_RATING
Definition: ItemTemplate.h:53
@ ITEM_MOD_ATTACK_POWER
Definition: ItemTemplate.h:61
@ ITEM_MOD_HASTE_RATING
Definition: ItemTemplate.h:59
@ ITEM_MOD_HIT_RANGED_RATING
Definition: ItemTemplate.h:40
@ ITEM_MOD_CRIT_SPELL_RATING
Definition: ItemTemplate.h:44
@ ITEM_MOD_BLOCK_VALUE
Definition: ItemTemplate.h:71
@ ITEM_MOD_CRIT_RANGED_RATING
Definition: ItemTemplate.h:43
@ ITEM_MOD_CRIT_MELEE_RATING
Definition: ItemTemplate.h:42
@ ITEM_MOD_STRENGTH
Definition: ItemTemplate.h:31
@ ITEM_MOD_HEALTH_REGEN
Definition: ItemTemplate.h:69
@ ITEM_MOD_BLOCK_RATING
Definition: ItemTemplate.h:38
@ ITEM_MOD_ARMOR_PENETRATION_RATING
Definition: ItemTemplate.h:67
@ ITEM_MOD_SPELL_HEALING_DONE
Definition: ItemTemplate.h:64
@ ITEM_MOD_CRIT_TAKEN_MELEE_RATING
Definition: ItemTemplate.h:48
@ ITEM_MOD_HIT_TAKEN_RATING
Definition: ItemTemplate.h:56
@ ITEM_MOD_HASTE_MELEE_RATING
Definition: ItemTemplate.h:51
@ ITEM_MOD_MANA_REGENERATION
Definition: ItemTemplate.h:66
@ ITEM_MOD_HIT_RATING
Definition: ItemTemplate.h:54
@ ITEM_MOD_INTELLECT
Definition: ItemTemplate.h:32
@ ITEM_MOD_RESILIENCE_RATING
Definition: ItemTemplate.h:58
@ ITEM_MOD_AGILITY
Definition: ItemTemplate.h:30
@ ITEM_MOD_DODGE_RATING
Definition: ItemTemplate.h:36
@ ITEM_MOD_CRIT_RATING
Definition: ItemTemplate.h:55
@ ITEM_MOD_SPELL_DAMAGE_DONE
Definition: ItemTemplate.h:65
@ ITEM_MOD_HIT_TAKEN_RANGED_RATING
Definition: ItemTemplate.h:46
uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemSubClass)
Definition: ItemTemplate.h:566
@ ITEM_SUBCLASS_ARMOR_MAIL
Definition: ItemTemplate.h:402
@ ITEM_SUBCLASS_ARMOR_CLOTH
Definition: ItemTemplate.h:400
@ ITEM_SUBCLASS_ARMOR_LEATHER
Definition: ItemTemplate.h:401
@ ITEM_SUBCLASS_ARMOR_SHIELD
Definition: ItemTemplate.h:405
@ ITEM_SUBCLASS_ARMOR_PLATE
Definition: ItemTemplate.h:403
@ ITEM_SUBCLASS_ARROW
Definition: ItemTemplate.h:425
@ ITEM_SUBCLASS_BULLET
Definition: ItemTemplate.h:426
@ ITEM_FLAGS_EXTRA_ALLIANCE_ONLY
Definition: ItemTemplate.h:221
@ ITEM_FLAGS_EXTRA_HORDE_ONLY
Definition: ItemTemplate.h:220
#define MAX_ITEM_PROTO_SPELLS
Definition: ItemTemplate.h:624
@ BIND_WHEN_PICKED_UP
Definition: ItemTemplate.h:97
ItemClass
Definition: ItemTemplate.h:299
@ ITEM_CLASS_PROJECTILE
Definition: ItemTemplate.h:306
@ ITEM_CLASS_ARMOR
Definition: ItemTemplate.h:304
@ ITEM_CLASS_WEAPON
Definition: ItemTemplate.h:302
@ ITEM_CLASS_CONSUMABLE
Definition: ItemTemplate.h:300
@ ITEM_SUBCLASS_FOOD
Definition: ItemTemplate.h:328
#define MAX_ITEM_PROTO_STATS
Definition: ItemTemplate.h:625
#define sLFGMgr
Definition: LFGMgr.h:636
@ LANG_NOT_EQUIPPED_ITEM
Definition: Language.h:720
@ LANG_PLAYER_DND
Definition: Language.h:721
@ LANG_PLAYER_AFK
Definition: Language.h:722
@ LANG_COMMAND_WHISPERON
Definition: Language.h:327
#define LOG_FATAL(filterType__,...)
Definition: Log.h:257
#define LOG_INFO(filterType__,...)
Definition: Log.h:269
#define LOG_ERROR(filterType__,...)
Definition: Log.h:261
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:273
#define sLootItemStorage
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true)
PermissionTypes
Definition: LootMgr.h:67
@ OWNER_PERMISSION
Definition: LootMgr.h:73
@ ALL_PERMISSION
Definition: LootMgr.h:68
@ RESTRICTED_PERMISSION
Definition: LootMgr.h:71
@ NONE_PERMISSION
Definition: LootMgr.h:74
@ ROUND_ROBIN_PERMISSION
Definition: LootMgr.h:72
@ MASTER_PERMISSION
Definition: LootMgr.h:70
@ GROUP_PERMISSION
Definition: LootMgr.h:69
GuidSet AllowedLooterSet
Definition: LootMgr.h:152
@ NEED_BEFORE_GREED
Definition: LootMgr.h:63
@ GROUP_LOOT
Definition: LootMgr.h:62
@ MASTER_LOOT
Definition: LootMgr.h:61
@ ROUND_ROBIN
Definition: LootMgr.h:60
@ FREE_FOR_ALL
Definition: LootMgr.h:59
LootError
Definition: LootMgr.h:96
@ LOOT_ERROR_DIDNT_KILL
Definition: LootMgr.h:97
@ LOOT_ERROR_ALREADY_PICKPOCKETED
Definition: LootMgr.h:108
LootType
Definition: LootMgr.h:78
@ LOOT_PICKPOCKETING
Definition: LootMgr.h:82
@ LOOT_MILLING
Definition: LootMgr.h:88
@ LOOT_FISHING_JUNK
Definition: LootMgr.h:92
@ LOOT_CORPSE
Definition: LootMgr.h:81
@ LOOT_FISHING
Definition: LootMgr.h:83
@ LOOT_INSIGNIA
Definition: LootMgr.h:91
@ LOOT_DISENCHANTING
Definition: LootMgr.h:84
@ LOOT_SKINNING
Definition: LootMgr.h:86
@ LOOT_FISHINGHOLE
Definition: LootMgr.h:90
@ LOOT_NONE
Definition: LootMgr.h:79
@ LOOT_PROSPECTING
Definition: LootMgr.h:87
@ MAIL_CHECK_MASK_COPIED
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:48
@ MAIL_STATIONERY_GM
Definition: Mail.h:58
@ MAIL_CREATURE
Definition: Mail.h:38
@ MAIL_NORMAL
Definition: Mail.h:36
#define SIZE_OF_GRIDS
Definition: MapDefines.h:13
#define sMapMgr
Definition: MapMgr.h:212
#define VISUAL_WAYPOINT
Definition: MotionMaster.h:32
@ PHASEMASK_ANYWHERE
Definition: Object.h:55
@ PHASEMASK_NORMAL
Definition: Object.h:54
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: Object.h:46
#define MAPID_INVALID
Definition: Object.h:458
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition: ObjectDefines.h:67
uint16 PAIR32_HIPART(uint32 x)
Definition: ObjectDefines.h:72
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
#define VISIBILITY_COMPENSATION
Definition: ObjectDefines.h:29
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:39
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ TYPEID_ITEM
Definition: ObjectGuid.h:35
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ TYPEMASK_SEER
Definition: ObjectGuid.h:56
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:51
@ TYPEMASK_PLAYER
Definition: ObjectGuid.h:52
SkillRangeType GetSkillRangeType(SkillRaceClassInfoEntry const *rcEntry)
Definition: ObjectMgr.cpp:8053
#define sObjectMgr
Definition: ObjectMgr.h:1546
std::pair< SpellClickInfoContainer::const_iterator, SpellClickInfoContainer::const_iterator > SpellClickInfoMapBounds
Definition: ObjectMgr.h:408
@ SKILL_RANGE_MONO
Definition: ObjectMgr.h:654
@ SKILL_RANGE_LANGUAGE
Definition: ObjectMgr.h:652
@ SKILL_RANGE_RANK
Definition: ObjectMgr.h:655
@ SKILL_RANGE_LEVEL
Definition: ObjectMgr.h:653
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
@ OUTDOOR_PVP_SI
Definition: OutdoorPvP.h:33
@ OUTDOOR_PVP_TF
Definition: OutdoorPvP.h:31
@ OUTDOOR_PVP_ZM
Definition: OutdoorPvP.h:32
@ OUTDOOR_PVP_EP
Definition: OutdoorPvP.h:34
@ OUTDOOR_PVP_NA
Definition: OutdoorPvP.h:30
@ OUTDOOR_PVP_HP
Definition: OutdoorPvP.h:29
#define sOutdoorPvPMgr
PetSaveMode
Definition: PetDefines.h:32
@ PET_SAVE_NOT_IN_SLOT
Definition: PetDefines.h:37
@ PET_SAVE_AS_CURRENT
Definition: PetDefines.h:34
@ PETSPELL_REMOVED
Definition: PetDefines.h:52
PetType
Definition: PetDefines.h:22
@ HUNTER_PET
Definition: PetDefines.h:24
@ PET_LOAD_SUMMON_PET
Definition: PetDefines.h:90
#define sPetitionMgr
Definition: PetitionMgr.h:88
std::map< ObjectGuid, Signatures > SignatureContainer
Definition: PetitionMgr.h:53
CharacterCustomizeFlags
Definition: Player.cpp:136
@ CHAR_CUSTOMIZE_FLAG_RACE
Definition: Player.cpp:140
@ CHAR_CUSTOMIZE_FLAG_NONE
Definition: Player.cpp:137
@ CHAR_CUSTOMIZE_FLAG_FACTION
Definition: Player.cpp:139
@ CHAR_CUSTOMIZE_FLAG_CUSTOMIZE
Definition: Player.cpp:138
static RuneType runeSlotTypes[MAX_RUNES]
Definition: Player.cpp:12634
CharacterFlags
Definition: Player.cpp:99
@ CHARACTER_FLAG_UNK1
Definition: Player.cpp:101
@ CHARACTER_FLAG_UNK19
Definition: Player.cpp:119
@ CHARACTER_FLAG_UNK27
Definition: Player.cpp:127
@ CHARACTER_FLAG_UNK2
Definition: Player.cpp:102
@ CHARACTER_FLAG_UNK30
Definition: Player.cpp:130
@ CHARACTER_FLAG_UNK24
Definition: Player.cpp:124
@ CHARACTER_FLAG_UNK10
Definition: Player.cpp:110
@ CHARACTER_FLAG_UNK18
Definition: Player.cpp:118
@ CHARACTER_FLAG_GHOST
Definition: Player.cpp:114
@ CHARACTER_FLAG_DECLINED
Definition: Player.cpp:126
@ CHARACTER_FLAG_UNK4
Definition: Player.cpp:104
@ CHARACTER_FLAG_UNK5
Definition: Player.cpp:105
@ CHARACTER_FLAG_HIDE_HELM
Definition: Player.cpp:111
@ CHARACTER_FLAG_HIDE_CLOAK
Definition: Player.cpp:112
@ CHARACTER_FLAG_UNK31
Definition: Player.cpp:131
@ CHARACTER_FLAG_UNK20
Definition: Player.cpp:120
@ CHARACTER_FLAG_UNK8
Definition: Player.cpp:108
@ CHARACTER_FLAG_UNK16
Definition: Player.cpp:116
@ CHARACTER_FLAG_UNK23
Definition: Player.cpp:123
@ CHARACTER_FLAG_UNK21
Definition: Player.cpp:121
@ CHARACTER_FLAG_UNK9
Definition: Player.cpp:109
@ CHARACTER_FLAG_LOCKED_BY_BILLING
Definition: Player.cpp:125
@ CHARACTER_LOCKED_FOR_TRANSFER
Definition: Player.cpp:103
@ CHARACTER_FLAG_RENAME
Definition: Player.cpp:115
@ CHARACTER_FLAG_UNK29
Definition: Player.cpp:129
@ CHARACTER_FLAG_UNK17
Definition: Player.cpp:117
@ CHARACTER_FLAG_UNK28
Definition: Player.cpp:128
@ CHARACTER_FLAG_UNK7
Definition: Player.cpp:107
@ CHARACTER_FLAG_NONE
Definition: Player.cpp:100
@ CHARACTER_FLAG_UNK13
Definition: Player.cpp:113
@ CHARACTER_FLAG_UNK6
Definition: Player.cpp:106
@ CHARACTER_FLAG_UNK22
Definition: Player.cpp:122
@ CHARACTER_FLAG_UNK32
Definition: Player.cpp:132
static uint32 copseReclaimDelay[MAX_DEATH_COUNT]
Definition: Player.cpp:143
@ NUM_CAI_SPELLS
Definition: Player.h:895
@ SPELL_ROOT_OR_FEAR
Definition: Player.h:886
@ SPELL_INSTANT_DAMAGE2
Definition: Player.h:888
@ SPELL_INSTANT_DAMAGE
Definition: Player.h:887
@ SPELL_T_CHARGE
Definition: Player.h:892
@ SPELL_DOT_DAMAGE
Definition: Player.h:891
@ SPELL_FAST_RUN
Definition: Player.h:894
@ SPELL_T_STUN
Definition: Player.h:885
@ SPELL_IMMUNITY
Definition: Player.h:893
#define SKILL_MAX(x)
Definition: Player.h:78
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:752
TrainerSpellState
Definition: Player.h:207
@ TRAINER_SPELL_GREEN
Definition: Player.h:208
@ TRAINER_SPELL_GRAY
Definition: Player.h:210
@ TRAINER_SPELL_GREEN_DISABLED
Definition: Player.h:211
@ TRAINER_SPELL_RED
Definition: Player.h:209
@ TELE_TO_WITH_PET
Definition: Player.h:800
@ TELE_TO_NOT_LEAVE_TAXI
Definition: Player.h:801
@ TELE_TO_NOT_LEAVE_VEHICLE
Definition: Player.h:799
@ TELE_TO_SPELL
Definition: Player.h:798
@ TELE_TO_NOT_LEAVE_COMBAT
Definition: Player.h:796
@ TELE_TO_NOT_UNSUMMON_PET
Definition: Player.h:797
@ TELE_TO_GM_MODE
Definition: Player.h:794
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition: Player.h:795
#define PLAYER_SKILL_BONUS_INDEX(x)
Definition: Player.h:75
EnviromentalDamage
Type of environmental damages.
Definition: Player.h:806
@ DAMAGE_SLIME
Definition: Player.h:811
@ DAMAGE_FALL
Definition: Player.h:809
@ DAMAGE_LAVA
Definition: Player.h:810
@ DAMAGE_FALL_TO_VOID
Definition: Player.h:813
@ DAMAGE_DROWNING
Definition: Player.h:808
@ DAMAGE_EXHAUSTED
Definition: Player.h:807
#define PLAYER_SKILL_VALUE_INDEX(x)
Definition: Player.h:74
RuneType
Definition: Player.h:391
@ RUNE_UNHOLY
Definition: Player.h:393
@ NUM_RUNE_TYPES
Definition: Player.h:396
@ RUNE_FROST
Definition: Player.h:394
@ RUNE_BLOOD
Definition: Player.h:392
#define SKILL_VALUE(x)
Definition: Player.h:77
#define KNOWN_TITLES_SIZE
Definition: Player.h:534
#define MAX_RUNES
Definition: Player.h:381
@ PLAYER_FIELD_BYTE_RELEASE_TIMER
Definition: Player.h:541
#define PLAYER_SKILL_INDEX(x)
Definition: Player.h:73
TransferAbortReason
Definition: Player.h:755
@ TRANSFER_ABORT_DIFFICULTY
Definition: Player.h:763
@ TRANSFER_ABORT_UNIQUE_MESSAGE
Definition: Player.h:764
@ TRANSFER_ABORT_MAP_NOT_ALLOWED
Definition: Player.h:771
@ TRANSFER_ABORT_INSUF_EXPAN_LVL
Definition: Player.h:762
@ PLAYER_EXTRA_GM_ON
Definition: Player.h:566
@ PLAYER_EXTRA_GM_INVISIBLE
Definition: Player.h:569
@ PLAYER_EXTRA_HAS_310_FLYER
Definition: Player.h:571
@ PLAYER_EXTRA_SHOW_DK_PET
Definition: Player.h:574
@ PLAYER_EXTRA_SPECTATOR_ON
Definition: Player.h:572
@ PLAYER_EXTRA_PVP_DEATH
Definition: Player.h:573
@ KEYRING_SLOT_START
Definition: Player.h:711
@ INVENTORY_SLOT_ITEM_START
Definition: Player.h:686
@ INVENTORY_SLOT_ITEM_END
Definition: Player.h:687
@ ITEM_ARENA_POINTS_ID
Definition: Player.h:931
@ ITEM_HONOR_POINTS_ID
Definition: Player.h:930
@ PLAYER_ALLOW_ONLY_ABILITY
Definition: Player.h:480
@ PLAYER_FLAGS_DND
Definition: Player.h:459
@ PLAYER_FLAGS_HIDE_CLOAK
Definition: Player.h:468
@ PLAYER_FLAGS_NO_XP_GAIN
Definition: Player.h:482
@ PLAYER_FLAGS_RESTING
Definition: Player.h:462
@ PLAYER_FLAGS_IS_OUT_OF_BOUNDS
Definition: Player.h:471
@ PLAYER_FLAGS_GHOST
Definition: Player.h:461
@ PLAYER_FLAGS_AFK
Definition: Player.h:458
@ PLAYER_FLAGS_GM
Definition: Player.h:460
@ PLAYER_FLAGS_HIDE_HELM
Definition: Player.h:467
@ ACTIONBUTTON_NEW
Definition: Player.h:218
@ ACTIONBUTTON_DELETED
Definition: Player.h:219
#define DEATH_EXPIRE_STEP
Definition: Player.h:70
EquipmentSetUpdateState
Definition: Player.h:722
@ EQUIPMENT_SET_CHANGED
Definition: Player.h:724
@ EQUIPMENT_SET_UNCHANGED
Definition: Player.h:723
@ EQUIPMENT_SET_DELETED
Definition: Player.h:726
@ EQUIPMENT_SET_NEW
Definition: Player.h:725
std::unordered_map< uint32, PlayerTalent * > PlayerTalentMap
Definition: Player.h:187
@ RUNE_GRACE_PERIOD
Definition: Player.h:386
@ RUNE_BASE_COOLDOWN
Definition: Player.h:385
@ CHEAT_POWER
Definition: Player.h:972
@ CHEAT_GOD
Definition: Player.h:969
@ CHEAT_NONE
Definition: Player.h:968
@ DELAYED_BG_GROUP_RESTORE
Flag to restore group state after teleport from BG.
Definition: Player.h:878
@ DELAYED_SAVE_PLAYER
Definition: Player.h:873
@ DELAYED_BG_MOUNT_RESTORE
Flag to restore mount state after teleport from BG.
Definition: Player.h:876
@ DELAYED_VEHICLE_TELEPORT
Definition: Player.h:879
@ DELAYED_BG_TAXI_RESTORE
Flag to restore taxi state after teleport from BG.
Definition: Player.h:877
@ DELAYED_SPELL_CAST_DESERTER
Definition: Player.h:875
@ DELAYED_RESURRECT_PLAYER
Definition: Player.h:874
RestFlag
Definition: Player.h:786
std::unordered_map< uint32, PlayerSpell * > PlayerSpellMap
Definition: Player.h:188
#define SKILL_TEMP_BONUS(x)
Definition: Player.h:81
#define SPEC_MASK_ALL
Definition: Player.h:172
ActionButtonType
Definition: Player.h:223
@ ACTION_BUTTON_ITEM
Definition: Player.h:229
@ ACTION_BUTTON_SPELL
Definition: Player.h:224
@ BUYBACK_SLOT_START
Definition: Player.h:705
#define MAX_TIMERS
Definition: Player.h:559
@ INVENTORY_SLOT_BAG_START
Definition: Player.h:680
@ INVENTORY_SLOT_BAG_END
Definition: Player.h:681
PlayerMovementType
Definition: Player.h:438
@ MOVE_ROOT
Definition: Player.h:439
@ MOVE_UNROOT
Definition: Player.h:440
@ MOVE_WATER_WALK
Definition: Player.h:441
@ MOVE_LAND_WALK
Definition: Player.h:442
#define MAX_TITLE_INDEX
Definition: Player.h:535
@ BANK_SLOT_BAG_END
Definition: Player.h:699
@ CURRENCYTOKEN_SLOT_END
Definition: Player.h:718
#define DISABLED_MIRROR_TIMER
Definition: Player.h:560
#define MAKE_SKILL_BONUS(t, p)
Definition: Player.h:83
@ PLAYED_TIME_TOTAL
Definition: Player.h:828
@ PLAYED_TIME_LEVEL
Definition: Player.h:829
EquipmentSlots
Definition: Player.h:654
@ EQUIPMENT_SLOT_BODY
Definition: Player.h:659
@ EQUIPMENT_SLOT_MAINHAND
Definition: Player.h:671
@ EQUIPMENT_SLOT_TABARD
Definition: Player.h:674
@ EQUIPMENT_SLOT_END
Definition: Player.h:675
@ EQUIPMENT_SLOT_OFFHAND
Definition: Player.h:672
@ EQUIPMENT_SLOT_START
Definition: Player.h:655
@ EQUIPMENT_SLOT_RANGED
Definition: Player.h:673
@ SPELLMOD_FLAT
Definition: Player.h:88
@ UNDERWATER_INDARKWATER
Definition: Player.h:99
@ UNDERWATER_NONE
Definition: Player.h:95
@ UNDERWATER_EXIST_TIMERS
Definition: Player.h:101
@ UNDERWATER_INWATER
Definition: Player.h:96
@ UNDERWATER_INLAVA
Definition: Player.h:97
@ RAID_INSTANCE_WARNING_MIN
Definition: Player.h:777
@ RAID_INSTANCE_WARNING_MIN_SOON
Definition: Player.h:778
@ RAID_INSTANCE_WARNING_HOURS
Definition: Player.h:776
@ RAID_INSTANCE_WELCOME
Definition: Player.h:779
#define PLAYER_MAX_DAILY_QUESTS
Definition: Player.h:66
#define MAX_DEATH_COUNT
Definition: Player.h:71
#define MAX_ACTION_BUTTONS
Definition: Player.h:269
AtLoginFlags
Definition: Player.h:579
@ AT_LOGIN_RESET_TALENTS
Definition: Player.h:583
@ AT_LOGIN_RESET_SPELLS
Definition: Player.h:582
@ AT_LOGIN_NONE
Definition: Player.h:580
@ AT_LOGIN_FIRST
Definition: Player.h:586
@ AT_LOGIN_RESURRECT
Definition: Player.h:592
@ AT_LOGIN_CUSTOMIZE
Definition: Player.h:584
@ AT_LOGIN_RENAME
Definition: Player.h:581
@ AT_LOGIN_CHANGE_RACE
Definition: Player.h:588
@ AT_LOGIN_CHANGE_FACTION
Definition: Player.h:587
#define MAX_MONEY_AMOUNT
Definition: Player.h:900
@ CHAR_DELETE_REMOVE
Definition: Player.h:923
@ CHAR_DELETE_UNLINK
Definition: Player.h:924
@ TALENT_TREE_HUNTER_SURVIVAL
Definition: Player.h:148
@ TALENT_TREE_DEATH_KNIGHT_FROST
Definition: Player.h:156
@ TALENT_TREE_MAGE_FIRE
Definition: Player.h:162
@ TALENT_TREE_PRIEST_SHADOW
Definition: Player.h:154
@ TALENT_TREE_DEATH_KNIGHT_BLOOD
Definition: Player.h:155
@ TALENT_TREE_DRUID_RESTORATION
Definition: Player.h:169
@ TALENT_TREE_SHAMAN_ELEMENTAL
Definition: Player.h:158
@ TALENT_TREE_SHAMAN_RESTORATION
Definition: Player.h:160
@ TALENT_TREE_PALADIN_PROTECTION
Definition: Player.h:144
@ TALENT_TREE_HUNTER_BEAST_MASTERY
Definition: Player.h:146
@ TALENT_TREE_DRUID_FERAL_COMBAT
Definition: Player.h:168
@ TALENT_TREE_WARLOCK_DEMONOLOGY
Definition: Player.h:165
@ TALENT_TREE_WARRIOR_FURY
Definition: Player.h:141
@ TALENT_TREE_WARLOCK_DESTRUCTION
Definition: Player.h:166
@ TALENT_TREE_ROGUE_ASSASSINATION
Definition: Player.h:149
@ TALENT_TREE_DEATH_KNIGHT_UNHOLY
Definition: Player.h:157
@ TALENT_TREE_WARLOCK_AFFLICTION
Definition: Player.h:164
@ TALENT_TREE_PRIEST_HOLY
Definition: Player.h:153
@ TALENT_TREE_SHAMAN_ENHANCEMENT
Definition: Player.h:159
@ TALENT_TREE_MAGE_ARCANE
Definition: Player.h:161
@ TALENT_TREE_PALADIN_HOLY
Definition: Player.h:143
@ TALENT_TREE_MAGE_FROST
Definition: Player.h:163
@ TALENT_TREE_WARRIOR_ARMS
Definition: Player.h:140
@ TALENT_TREE_DRUID_BALANCE
Definition: Player.h:167
@ TALENT_TREE_ROGUE_COMBAT
Definition: Player.h:150
@ TALENT_TREE_HUNTER_MARKSMANSHIP
Definition: Player.h:147
@ TALENT_TREE_PALADIN_RETRIBUTION
Definition: Player.h:145
@ TALENT_TREE_ROGUE_SUBTLETY
Definition: Player.h:151
@ TALENT_TREE_WARRIOR_PROTECTION
Definition: Player.h:142
@ TALENT_TREE_PRIEST_DISCIPLINE
Definition: Player.h:152
@ REST_STATE_RESTED
Definition: Player.h:954
@ REST_STATE_RAF_LINKED
Definition: Player.h:956
@ REST_STATE_NOT_RAF_LINKED
Definition: Player.h:955
#define PLAYER_MAX_SKILLS
Definition: Player.h:65
MirrorTimerType
Definition: Player.h:554
@ FIRE_TIMER
Definition: Player.h:557
@ FATIGUE_TIMER
Definition: Player.h:555
@ BREATH_TIMER
Definition: Player.h:556
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:651
@ SKILL_DELETED
Definition: Player.h:623
@ SKILL_CHANGED
Definition: Player.h:621
@ SKILL_UNCHANGED
Definition: Player.h:620
@ SKILL_NEW
Definition: Player.h:622
#define PLAYER_EXPLORED_ZONES_SIZE
Definition: Player.h:67
DrunkenState
Definition: Player.h:446
@ DRUNKEN_TIPSY
Definition: Player.h:448
@ DRUNKEN_DRUNK
Definition: Player.h:449
@ DRUNKEN_SOBER
Definition: Player.h:447
@ DRUNKEN_SMASHED
Definition: Player.h:450
ReputationSource
Definition: Player.h:233
@ REPUTATION_SOURCE_KILL
Definition: Player.h:234
@ REPUTATION_SOURCE_SPELL
Definition: Player.h:240
@ REPUTATION_SOURCE_QUEST
Definition: Player.h:235
@ REPUTATION_SOURCE_MONTHLY_QUEST
Definition: Player.h:238
@ REPUTATION_SOURCE_REPEATABLE_QUEST
Definition: Player.h:239
@ REPUTATION_SOURCE_WEEKLY_QUEST
Definition: Player.h:237
@ REPUTATION_SOURCE_DAILY_QUEST
Definition: Player.h:236
@ CHAT_TAG_DND
Definition: Player.h:820
@ CHAT_TAG_DEV
Definition: Player.h:823
@ CHAT_TAG_AFK
Definition: Player.h:819
@ CHAT_TAG_GM
Definition: Player.h:821
@ CHAT_TAG_NONE
Definition: Player.h:818
#define MAKE_SKILL_VALUE(v, m)
Definition: Player.h:79
#define MAX_ACTION_BUTTON_ACTION_VALUE
Definition: Player.h:245
#define SKILL_PERM_BONUS(x)
Definition: Player.h:82
PlayerSpellState
Definition: Player.h:113
@ PLAYERSPELL_REMOVED
Definition: Player.h:117
@ PLAYERSPELL_UNCHANGED
Definition: Player.h:114
@ PLAYERSPELL_CHANGED
Definition: Player.h:115
@ PLAYERSPELL_NEW
Definition: Player.h:116
@ PLAYERSPELL_TEMPORARY
Definition: Player.h:118
@ PLAYER_SLOTS_COUNT
Definition: Player.h:648
@ PLAYER_SLOT_START
Definition: Player.h:645
@ PLAYER_SLOT_END
Definition: Player.h:647
#define QUEST_OBJECTIVES_COUNT
Definition: QuestDef.h:35
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:33
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:103
#define QUEST_REPUTATIONS_COUNT
Definition: QuestDef.h:41
@ DIALOG_STATUS_NONE
Definition: QuestDef.h:112
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
bool roll_chance_f(float chance)
Definition: Random.h:53
bool roll_chance_i(int chance)
Definition: Random.h:59
@ REALM_TYPE_RPPVP
Definition: Realm.h:57
@ REALM_TYPE_PVP
Definition: Realm.h:54
#define sScriptMgr
Definition: ScriptMgr.h:2048
ServerSideVisibilityType
@ SERVERSIDE_VISIBILITY_GM
GameobjectTypes
@ GAMEOBJECT_TYPE_CHEST
@ GAMEOBJECT_TYPE_QUESTGIVER
@ EFFECT_0
Definition: SharedDefines.h:30
#define MAX_STATS
Powers
@ MAX_POWERS
@ POWER_RAGE
@ POWER_HEALTH
@ POWER_RUNIC_POWER
@ POWER_HAPPINESS
@ POWER_ENERGY
@ POWER_MANA
@ POWER_RUNE
@ POWER_FOCUS
#define MAX_TALENT_SPECS
@ CHAT_MSG_SAY
@ CHAT_MSG_WHISPER_INFORM
@ CHAT_MSG_YELL
@ CHAT_MSG_WHISPER
@ CHAT_MSG_EMOTE
SpellSchools
@ SPELL_ATTR7_IGNORES_COLD_WEATHER_FLYING_REQUIREMENT
@ SPELL_ATTR7_ATTACK_ON_CHARGE_TO_UNIT
@ SPELL_EFFECT_ADD_EXTRA_ATTACKS
@ SPELL_EFFECT_TRADE_SKILL
@ SPELL_EFFECT_SUMMON
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ SPELL_EFFECT_LEARN_SPELL
@ SPELL_EFFECT_SKILL_STEP
#define CLASSMASK_WAND_USERS
Language
@ LANG_UNIVERSAL
@ LANG_ADDON
@ SPELL_PREVENTION_TYPE_SILENCE
MailResponseType
@ MAIL_ITEM_TAKEN
@ GENDER_MALE
Definition: SharedDefines.h:60
@ GENDER_FEMALE
Definition: SharedDefines.h:61
@ SPELL_ATTR5_NO_REAGENT_COST_WITH_AURA
constexpr auto MAX_SPELL_SCHOOL
@ BATTLEGROUND_QUEUE_NONE
@ CORPSE_DYNFLAG_LOOTABLE
@ SPELL_ATTR2_ALLOW_WHILE_NOT_SHAPESHIFTED
@ INVISIBILITY_DRUNK
RemoveMethod
@ UNIT_DYNFLAG_LOOTABLE
@ UNIT_DYNFLAG_NONE
@ UNIT_DYNFLAG_REFER_A_FRIEND
@ ITEM_QUALITY_HEIRLOOM
TeamId
@ TEAM_NEUTRAL
@ TEAM_ALLIANCE
@ TEAM_HORDE
DuelCompleteType
@ DUEL_FLED
@ DUEL_WON
@ DUEL_INTERRUPTED
#define MAX_GLYPH_SLOT_INDEX
@ CLASS_HUNTER
@ CLASS_DRUID
@ CLASS_SHAMAN
@ CLASS_PRIEST
@ CLASS_WARRIOR
@ CLASS_WARLOCK
@ CLASS_MAGE
@ CLASS_DEATH_KNIGHT
@ CLASS_PALADIN
@ CLASS_ROGUE
@ SPELLFAMILY_MAGE
MailResponseResult
@ MAIL_ERR_EQUIP_ERROR
SpellAttr0
@ SPELL_ATTR0_ONLY_OUTDOORS
@ SPELL_ATTR0_PASSIVE
@ SPELL_ATTR0_DO_NOT_DISPLAY
@ SPELL_ATTR0_NOT_IN_COMBAT_ONLY_PEACEFUL
#define MAX_CLASSES
ReputationRank
@ REP_UNFRIENDLY
@ REP_NEUTRAL
@ GOLD
@ SPELL_VISUAL_KIT_DRINK
@ SPELL_VISUAL_KIT_FOOD
BattlegroundTypeId
@ BATTLEGROUND_IC
@ BATTLEGROUND_WS
@ BATTLEGROUND_EY
@ BATTLEGROUND_AV
@ BATTLEGROUND_BE
@ BATTLEGROUND_RV
@ BATTLEGROUND_NA
@ BATTLEGROUND_DS
@ BATTLEGROUND_SA
@ BATTLEGROUND_AB
@ BATTLEGROUND_RL
@ TRAINER_TYPE_CLASS
@ RACE_NIGHTELF
Definition: SharedDefines.h:73
@ FACTION_FRIENDLY
AuraStateType
@ AURA_STATE_HEALTHLESS_35_PERCENT
@ AURA_STATE_HEALTH_ABOVE_75_PERCENT
@ AURA_STATE_HEALTHLESS_20_PERCENT
@ SPELL_CATEGORY_DRINK
@ SPELL_CATEGORY_FOOD
Stats
@ STAT_SPIRIT
@ STAT_INTELLECT
@ STAT_AGILITY
@ STAT_STRENGTH
@ STAT_STAMINA
@ ERR_TAXIPLAYERBUSY
@ ERR_TAXIOK
@ ERR_TAXINOSUCHPATH
@ ERR_TAXIUNSPECIFIEDSERVERERROR
@ ERR_TAXIPLAYERSHAPESHIFTED
@ ERR_TAXITOOFARAWAY
@ ERR_TAXIPLAYERALREADYMOUNTED
@ ERR_TAXINOTENOUGHMONEY
SpellCastResult
@ SPELL_CAST_OK
#define PLAYER_MAX_BATTLEGROUND_QUEUES
@ SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS
@ CREATURE_TYPE_FLAG_VISIBLE_TO_GHOSTS
@ CREATURE_TYPE_FLAG_INTERACT_WHILE_DEAD
@ SKILL_UNARMED
@ SKILL_RUNEFORGING
@ SKILL_LOCKPICKING
@ SKILL_MOUNTS
@ SKILL_FIST_WEAPONS
PartyResult
@ ERR_PARTY_LFG_BOOT_LOOT_ROLLS
@ ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S
@ ERR_PARTY_LFG_BOOT_LIMIT
@ ERR_NOT_LEADER
@ ERR_NOT_IN_GROUP
@ ERR_PARTY_LFG_BOOT_DUNGEON_COMPLETE
@ ERR_PARTY_LFG_BOOT_IN_COMBAT
@ ERR_PARTY_LFG_BOOT_IN_PROGRESS
@ ERR_INVITE_RESTRICTED
@ ERR_PARTY_RESULT_OK
@ ERR_PARTY_LFG_BOOT_TOO_FEW_PLAYERS
@ SPELL_ATTR6_NO_CATEGORY_COOLDOWN_MODS
SpellSchoolMask
@ SPELL_SCHOOL_MASK_NORMAL
@ SPELL_SCHOOL_MASK_ALL
@ SPELL_SCHOOL_MASK_NATURE
@ SPELL_SCHOOL_MASK_FIRE
@ FRIEND_REMOVED
Definition: SocialMgr.h:71
#define sSocialMgr
Definition: SocialMgr.h:147
@ SOCIAL_FLAG_ALL
Definition: SocialMgr.h:44
@ SPELL_STATE_DELAYED
Definition: Spell.h:228
AuraType
@ SPELL_AURA_PREVENT_RESURRECTION
@ SPELL_AURA_RETAIN_COMBO_POINTS
@ SPELL_AURA_MOD_SKILL
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_PREVENT_DURABILITY_LOSS
@ SPELL_AURA_MOD_SHAPESHIFT
@ SPELL_AURA_MOD_WATER_BREATHING
@ SPELL_AURA_FEATHER_FALL
@ SPELL_AURA_MOD_REGEN_DURING_COMBAT
@ SPELL_AURA_MOD_POSSESS_PET
@ SPELL_AURA_MOD_INCREASE_SPEED
@ SPELL_AURA_CONVERT_RUNE
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_INTERRUPT_REGEN
@ SPELL_AURA_MOD_POWER_REGEN
@ SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
@ SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
@ SPELL_AURA_DUMMY
@ SPELL_AURA_MOD_REPUTATION_GAIN
@ SPELL_AURA_FLY
@ SPELL_AURA_MOD_FAKE_INEBRIATE
@ SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
@ SPELL_AURA_WATER_WALK
@ SPELL_AURA_SAFE_FALL
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_HOVER
@ SPELL_AURA_SCHOOL_IMMUNITY
@ SPELL_AURA_MOUNTED
@ SPELL_AURA_MOD_HONOR_GAIN_PCT
@ SPELL_AURA_MOD_COOLDOWN
@ SPELL_AURA_TRANSFORM
@ SPELL_AURA_MOD_WEAPON_CRIT_PERCENT
@ SPELL_AURA_WATER_BREATHING
@ SPELL_AURA_MOD_POWER_REGEN_PERCENT
@ SPELL_AURA_MOD_DAMAGE_DONE
@ SPELL_AURA_NO_PVP_CREDIT
@ SPELL_AURA_MOD_CONFUSE
@ SPELL_AURA_MOD_POSSESS
@ SPELL_AURA_PREVENT_REGENERATE_POWER
@ SPELL_AURA_NONE
@ SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED
@ SPELL_AURA_MOD_REGEN
@ SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
@ SPELL_AURA_MOD_SKILL_TALENT
@ SPELL_AURA_MOD_STUN
@ SPELL_AURA_BIND_SIGHT
@ AURA_EFFECT_HANDLE_REAL
@ AURA_EFFECT_HANDLE_SKILL
@ AURA_EFFECT_HANDLE_SEND_FOR_CLIENT
bool IsProfessionOrRidingSkill(uint32 skill)
Definition: SpellMgr.h:597
std::pair< SpellsRequiringSpellMap::const_iterator, SpellsRequiringSpellMap::const_iterator > SpellsRequiringSpellMapBounds
Definition: SpellMgr.h:554
#define sSpellMgr
Definition: SpellMgr.h:794
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
Definition: SpellMgr.h:568
@ PROC_FLAG_TAKEN_DAMAGE
Definition: SpellMgr.h:137
#define sTicketMgr
Definition: TicketMgr.h:259
#define MAX_SPELL_CHARM
Definition: Unit.h:266
@ AURA_INTERRUPT_FLAG_MOVE
Definition: Unit.h:55
@ AURA_INTERRUPT_FLAG_TURNING
Definition: Unit.h:56
@ AURA_INTERRUPT_FLAG_NOT_ABOVEWATER
Definition: Unit.h:59
@ AURA_INTERRUPT_FLAG_NOT_SEATED
Definition: Unit.h:70
@ AURA_INTERRUPT_FLAG_NOT_UNDERWATER
Definition: Unit.h:60
@ AURA_INTERRUPT_FLAG_CHANGE_MAP
Definition: Unit.h:71
@ MOVEMENTFLAG_ONTRANSPORT
Definition: Unit.h:709
@ MOVEMENTFLAG_FLYING
Definition: Unit.h:725
@ MOVEMENTFLAG_MASK_HAS_PLAYER_STATUS_OPCODE
Movement flags that have change status opcodes associated for players.
Definition: Unit.h:749
@ UNIT_MASK_PUPPET
Definition: Unit.h:829
@ UNIT_MASK_ACCESSORY
Definition: Unit.h:832
BaseModType
Definition: Unit.h:466
@ FLAT_MOD
Definition: Unit.h:467
@ PCT_MOD
Definition: Unit.h:468
static constexpr uint32 infinityCooldownDelayCheck
Definition: Unit.h:264
#define MAX_UNIT_ACTION_BAR_INDEX
Definition: Unit.h:1219
WeaponAttackType
Definition: Unit.h:554
@ OFF_ATTACK
Definition: Unit.h:556
@ MAX_ATTACK
Definition: Unit.h:558
@ BASE_ATTACK
Definition: Unit.h:555
@ RANGED_ATTACK
Definition: Unit.h:557
@ SPELLMOD_CHANCE_OF_SUCCESS
Definition: Unit.h:103
@ SPELLMOD_COOLDOWN
Definition: Unit.h:96
@ SPELLMOD_DURATION
Definition: Unit.h:86
@ MINDAMAGE
Definition: Unit.h:380
@ MAXDAMAGE
Definition: Unit.h:381
@ SPELLVALUE_BASE_POINT0
Definition: Unit.h:122
UnitMods
Definition: Unit.h:420
@ UNIT_MOD_DAMAGE_OFFHAND
Definition: Unit.h:444
@ UNIT_MOD_STAT_INTELLECT
Definition: Unit.h:424
@ UNIT_MOD_STAT_SPIRIT
Definition: Unit.h:425
@ UNIT_MOD_ARMOR
Definition: Unit.h:434
@ UNIT_MOD_RESISTANCE_SHADOW
Definition: Unit.h:439
@ UNIT_MOD_RESISTANCE_FROST
Definition: Unit.h:438
@ UNIT_MOD_END
Definition: Unit.h:446
@ UNIT_MOD_ATTACK_POWER
Definition: Unit.h:441
@ UNIT_MOD_RESISTANCE_HOLY
Definition: Unit.h:435
@ UNIT_MOD_RESISTANCE_ARCANE
Definition: Unit.h:440
@ UNIT_MOD_HEALTH
Definition: Unit.h:426
@ UNIT_MOD_DAMAGE_RANGED
Definition: Unit.h:445
@ UNIT_MOD_RESISTANCE_FIRE
Definition: Unit.h:436
@ UNIT_MOD_STAT_STRENGTH
Definition: Unit.h:421
@ UNIT_MOD_RESISTANCE_NATURE
Definition: Unit.h:437
@ UNIT_MOD_STAT_AGILITY
Definition: Unit.h:422
@ UNIT_MOD_DAMAGE_MAINHAND
Definition: Unit.h:443
@ UNIT_MOD_MANA
Definition: Unit.h:427
@ UNIT_MOD_STAT_START
Definition: Unit.h:448
@ UNIT_MOD_STAT_STAMINA
Definition: Unit.h:423
@ UNIT_MOD_ATTACK_POWER_RANGED
Definition: Unit.h:442
@ UNIT_BYTE1_FLAG_GROUND
Definition: Unit.h:188
@ UNIT_BYTE1_FLAG_ALWAYS_STAND
Definition: Unit.h:189
DeathState
Definition: Unit.h:474
@ CORPSE
Definition: Unit.h:477
@ ALIVE
Definition: Unit.h:475
@ JUST_DIED
Definition: Unit.h:476
#define BASE_ATTACK_TIME
Definition: Unit.h:149
static constexpr uint32 infinityCooldownDelay
Definition: Unit.h:263
#define MAX_MOVE_TYPE
Definition: Unit.h:548
@ SPELL_COOLDOWN_FLAG_NONE
Definition: Unit.h:1356
@ UNIT_STAND_FLAGS_ALL
Definition: Unit.h:182
#define MAX_COMBAT_RATING
Definition: Unit.h:590
BaseModGroup
Definition: Unit.h:457
@ OFFHAND_CRIT_PERCENTAGE
Definition: Unit.h:460
@ BASEMOD_END
Definition: Unit.h:462
@ SHIELD_BLOCK_VALUE
Definition: Unit.h:461
@ CRIT_PERCENTAGE
Definition: Unit.h:458
@ RANGED_CRIT_PERCENTAGE
Definition: Unit.h:459
@ AURA_REMOVE_BY_EXPIRE
Definition: Unit.h:390
TriggerCastFlags
Definition: Unit.h:395
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition: Unit.h:413
@ TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD
Will ignore GCD.
Definition: Unit.h:398
@ TRIGGERED_IGNORE_CASTER_AURASTATE
Will ignore shapeshift checks.
Definition: Unit.h:408
@ TRIGGERED_IGNORE_SHAPESHIFT
Will not adjust facing to target (if any)
Definition: Unit.h:407
@ TRIGGERED_NONE
Definition: Unit.h:396
UnitModifierType
Definition: Unit.h:370
@ BASE_VALUE
Definition: Unit.h:371
@ TOTAL_VALUE
Definition: Unit.h:373
@ TOTAL_PCT
Definition: Unit.h:374
@ BASE_PCT
Definition: Unit.h:372
#define MAKE_UNIT_ACTION_BUTTON(A, T)
Definition: Unit.h:1166
#define CURRENT_MAX_SPELL
Definition: Unit.h:1113
CombatRating
Definition: Unit.h:562
@ CR_EXPERTISE
Definition: Unit.h:586
@ CR_HIT_TAKEN_MELEE
Definition: Unit.h:574
@ CR_HASTE_RANGED
Definition: Unit.h:581
@ CR_HIT_MELEE
Definition: Unit.h:568
@ CR_CRIT_TAKEN_RANGED
Definition: Unit.h:578
@ CR_CRIT_TAKEN_SPELL
Definition: Unit.h:579
@ CR_ARMOR_PENETRATION
Definition: Unit.h:587
@ CR_CRIT_MELEE
Definition: Unit.h:571
@ CR_CRIT_RANGED
Definition: Unit.h:572
@ CR_HIT_TAKEN_SPELL
Definition: Unit.h:576
@ CR_PARRY
Definition: Unit.h:566
@ CR_DODGE
Definition: Unit.h:565
@ CR_DEFENSE_SKILL
Definition: Unit.h:564
@ CR_HASTE_MELEE
Definition: Unit.h:580
@ CR_BLOCK
Definition: Unit.h:567
@ CR_HASTE_SPELL
Definition: Unit.h:582
@ CR_HIT_SPELL
Definition: Unit.h:570
@ CR_HIT_TAKEN_RANGED
Definition: Unit.h:575
@ CR_CRIT_SPELL
Definition: Unit.h:573
@ CR_HIT_RANGED
Definition: Unit.h:569
@ CR_CRIT_TAKEN_MELEE
Definition: Unit.h:577
@ UNIT_BYTES_1_OFFSET_ANIM_TIER
Definition: Unit.h:156
@ NULL_BAG
Definition: Unit.h:319
@ NULL_SLOT
Definition: Unit.h:320
@ UNIT_NPC_FLAG_VENDOR
Definition: Unit.h:675
@ UNIT_NPC_FLAG_QUESTGIVER
Definition: Unit.h:669
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: Unit.h:692
@ UNIT_NPC_FLAG_TRAINER_CLASS
Definition: Unit.h:673
@ UNIT_NPC_FLAG_TRAINER
Definition: Unit.h:672
ShapeshiftForm
Definition: Unit.h:198
@ FORM_DIREBEAR
Definition: Unit.h:207
@ FORM_CAT
Definition: Unit.h:200
@ FORM_GHOSTWOLF
Definition: Unit.h:215
@ FORM_GHOUL
Definition: Unit.h:206
@ FORM_BEAR
Definition: Unit.h:204
#define BASE_MAXDAMAGE
Definition: Unit.h:148
CurrentSpellTypes
Definition: Unit.h:1105
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:1108
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:1107
@ CURRENT_AUTOREPEAT_SPELL
Definition: Unit.h:1109
static constexpr uint32 MAX_CREATURE_SPELLS
Definition: Unit.h:262
std::unordered_map< uint32, uint32 > PacketCooldowns
Definition: Unit.h:1361
@ UNIT_BYTE2_FLAG_PVP
Definition: Unit.h:245
@ UNIT_BYTE2_FLAG_FFA_PVP
Definition: Unit.h:247
@ UNIT_BYTE2_FLAG_SANCTUARY
Definition: Unit.h:248
#define MAX_SPELLMOD
Definition: Unit.h:118
@ UNIT_STATE_CONFUSED
Definition: Unit.h:495
@ UNIT_STATE_ROOT
Definition: Unit.h:494
@ UNIT_STATE_ISOLATED
Definition: Unit.h:497
@ UNIT_STATE_FLEEING
Definition: Unit.h:491
@ UNIT_STATE_STUNNED
Definition: Unit.h:487
#define MAX_SPELL_CONTROL_BAR
Definition: Unit.h:269
#define BASE_MINDAMAGE
Definition: Unit.h:147
@ UNIT_FLAG_TAXI_FLIGHT
Definition: Unit.h:626
@ UNIT_FLAG_STUNNED
Definition: Unit.h:624
@ UNIT_FLAG_NON_ATTACKABLE
Definition: Unit.h:607
@ UNIT_FLAG_IN_COMBAT
Definition: Unit.h:625
@ UNIT_FLAG_PREPARATION
Definition: Unit.h:611
@ UNIT_FLAG_IMMUNE_TO_NPC
Definition: Unit.h:615
@ UNIT_FLAG_DISARMED
Definition: Unit.h:627
@ UNIT_FLAG_PACIFIED
Definition: Unit.h:623
@ UNIT_FLAG_CONFUSED
Definition: Unit.h:628
@ UNIT_FLAG_DISABLE_MOVE
Definition: Unit.h:608
@ UNIT_FLAG_FLEEING
Definition: Unit.h:629
@ UNIT_FLAG_NOT_SELECTABLE
Definition: Unit.h:631
@ UNIT_FLAG_LOOTING
Definition: Unit.h:616
@ UNIT_FLAG_IMMUNE_TO_PC
Definition: Unit.h:614
@ UNIT_FLAG_NOT_ATTACKABLE_1
Definition: Unit.h:613
@ UNIT_FLAG_SILENCED
Definition: Unit.h:619
@ UNIT_FLAG_PLAYER_CONTROLLED
Definition: Unit.h:609
@ UNIT_FLAG_SKINNABLE
Definition: Unit.h:632
@ UNIT_FLAG_MOUNT
Definition: Unit.h:633
@ UNIT_FLAG_PET_IN_COMBAT
Definition: Unit.h:617
@ UNIT_FLAG2_ALLOW_CHEAT_SPELLS
Definition: Unit.h:660
@ UNIT_FLAG2_REGENERATE_POWER
Definition: Unit.h:653
@ SELF_DAMAGE
Definition: Unit.h:599
@ DIRECT_DAMAGE
Definition: Unit.h:594
@ CORPSE_FIELD_BYTES_2
Definition: UpdateFields.h:425
@ CORPSE_FIELD_FLAGS
Definition: UpdateFields.h:427
@ CORPSE_FIELD_BYTES_1
Definition: UpdateFields.h:424
@ CORPSE_FIELD_DISPLAY_ID
Definition: UpdateFields.h:422
@ CORPSE_FIELD_ITEM
Definition: UpdateFields.h:423
@ CORPSE_FIELD_GUILD
Definition: UpdateFields.h:426
@ CORPSE_FIELD_DYNAMIC_FLAGS
Definition: UpdateFields.h:428
@ PLAYER_FIELD_MOD_DAMAGE_DONE_POS
Definition: UpdateFields.h:360
@ UNIT_FIELD_MINDAMAGE
Definition: UpdateFields.h:127
@ PLAYER_FIELD_TODAY_CONTRIBUTION
Definition: UpdateFields.h:375
@ PLAYER_EXPERTISE
Definition: UpdateFields.h:349
@ PLAYER_RANGED_CRIT_PERCENTAGE
Definition: UpdateFields.h:352
@ PLAYER_BYTES_3
Definition: UpdateFields.h:183
@ PLAYER_NEXT_LEVEL_XP
Definition: UpdateFields.h:340
@ PLAYER_GUILD_TIMESTAMP
Definition: UpdateFields.h:185
@ UNIT_NPC_FLAGS
Definition: UpdateFields.h:139
@ PLAYER_GUILDID
Definition: UpdateFields.h:179
@ PLAYER_CRIT_PERCENTAGE
Definition: UpdateFields.h:351
@ PLAYER_SPELL_CRIT_PERCENTAGE1
Definition: UpdateFields.h:354
@ PLAYER_FIELD_DAILY_QUESTS_1
Definition: UpdateFields.h:385
@ PLAYER_FIELD_COINAGE
Definition: UpdateFields.h:359
@ PLAYER_FIELD_ARENA_CURRENCY
Definition: UpdateFields.h:383
@ PLAYER_FIELD_COMBAT_RATING_1
Definition: UpdateFields.h:380
@ PLAYER_XP
Definition: UpdateFields.h:339
@ UNIT_FIELD_POWER_COST_MODIFIER
Definition: UpdateFields.h:170
@ UNIT_FIELD_RANGEDATTACKTIME
Definition: UpdateFields.h:121
@ UNIT_FIELD_ATTACK_POWER_MODS
Definition: UpdateFields.h:163
@ PLAYER_PARRY_PERCENTAGE
Definition: UpdateFields.h:348
@ PLAYER_NO_REAGENT_COST_1
Definition: UpdateFields.h:387
@ PLAYER_OFFHAND_CRIT_PERCENTAGE
Definition: UpdateFields.h:353
@ PLAYER_SHIELD_BLOCK
Definition: UpdateFields.h:355
@ PLAYER_CHOSEN_TITLE
Definition: UpdateFields.h:324
@ UNIT_FIELD_MAXDAMAGE
Definition: UpdateFields.h:128
@ PLAYER_FIELD_MOD_TARGET_RESISTANCE
Definition: UpdateFields.h:366
@ PLAYER_EXPLORED_ZONES_1
Definition: UpdateFields.h:357
@ PLAYER_FIELD_HONOR_CURRENCY
Definition: UpdateFields.h:382
@ PLAYER_FIELD_KNOWN_CURRENCIES
Definition: UpdateFields.h:338
@ PLAYER_BLOCK_PERCENTAGE
Definition: UpdateFields.h:346
@ UNIT_FIELD_BYTES_0
Definition: UpdateFields.h:95
@ UNIT_FIELD_LEVEL
Definition: UpdateFields.h:114
@ PLAYER_BYTES_2
Definition: UpdateFields.h:182
@ UNIT_FIELD_RANGED_ATTACK_POWER
Definition: UpdateFields.h:165
@ UNIT_MOD_CAST_SPEED
Definition: UpdateFields.h:137
@ UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER
Definition: UpdateFields.h:167
@ UNIT_FIELD_MAXOFFHANDDAMAGE
Definition: UpdateFields.h:130
@ PLAYER_FIELD_BYTES2
Definition: UpdateFields.h:378
@ PLAYER_FLAGS
Definition: UpdateFields.h:178
@ PLAYER_GUILDRANK
Definition: UpdateFields.h:180
@ UNIT_FIELD_FLAGS_2
Definition: UpdateFields.h:118
@ UNIT_FIELD_AURASTATE
Definition: UpdateFields.h:119
@ UNIT_FIELD_MOUNTDISPLAYID
Definition: UpdateFields.h:126
@ PLAYER__FIELD_KNOWN_TITLES
Definition: UpdateFields.h:335
@ UNIT_FIELD_MAXRANGEDDAMAGE
Definition: UpdateFields.h:169
@ PLAYER_DODGE_PERCENTAGE
Definition: UpdateFields.h:347
@ PLAYER_RUNE_REGEN_1
Definition: UpdateFields.h:386
@ UNIT_FIELD_ATTACK_POWER_MULTIPLIER
Definition: UpdateFields.h:164
@ UNIT_FIELD_ATTACK_POWER
Definition: UpdateFields.h:162
@ PLAYER_GLYPHS_ENABLED
Definition: UpdateFields.h:390
@ PLAYER_OFFHAND_EXPERTISE
Definition: UpdateFields.h:350
@ UNIT_FIELD_POWER1
Definition: UpdateFields.h:97
@ PLAYER_BYTES
Definition: UpdateFields.h:181
@ PLAYER_FIELD_ARENA_TEAM_INFO_1_1
Definition: UpdateFields.h:381
@ PLAYER_FIELD_MOD_HEALING_DONE_POS
Definition: UpdateFields.h:363
@ PLAYER_CHARACTER_POINTS1
Definition: UpdateFields.h:342
@ PLAYER_AMMO_ID
Definition: UpdateFields.h:369
@ PLAYER_FIELD_KILLS
Definition: UpdateFields.h:374
@ PLAYER_FIELD_YESTERDAY_CONTRIBUTION
Definition: UpdateFields.h:376
@ UNIT_FIELD_MINRANGEDDAMAGE
Definition: UpdateFields.h:168
@ UNIT_FIELD_FLAGS
Definition: UpdateFields.h:117
@ PLAYER_FIELD_WATCHED_FACTION_INDEX
Definition: UpdateFields.h:379
@ PLAYER_VISIBLE_ITEM_1_ENTRYID
Definition: UpdateFields.h:286
@ UNIT_FIELD_TARGET
Definition: UpdateFields.h:92
@ PLAYER_FIELD_LIFETIME_HONORABLE_KILLS
Definition: UpdateFields.h:377
@ UNIT_FIELD_RANGED_ATTACK_POWER_MODS
Definition: UpdateFields.h:166
@ UNIT_FIELD_HOVERHEIGHT
Definition: UpdateFields.h:173
@ PLAYER_SELF_RES_SPELL
Definition: UpdateFields.h:370
@ PLAYER_FARSIGHT
Definition: UpdateFields.h:334
@ PLAYER_DUEL_TEAM
Definition: UpdateFields.h:184
@ PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
Definition: UpdateFields.h:362
@ PLAYER_FIELD_BYTES
Definition: UpdateFields.h:368
@ UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER
Definition: UpdateFields.h:113
@ UNIT_FIELD_BYTES_1
Definition: UpdateFields.h:131
@ UNIT_FIELD_POWER_COST_MULTIPLIER
Definition: UpdateFields.h:171
@ PLAYER_END
Definition: UpdateFields.h:392
@ PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
Definition: UpdateFields.h:361
@ PLAYER_DUEL_ARBITER
Definition: UpdateFields.h:177
@ UNIT_FIELD_BYTES_2
Definition: UpdateFields.h:161
@ PLAYER_REST_STATE_EXPERIENCE
Definition: UpdateFields.h:358
@ UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER
Definition: UpdateFields.h:112
@ UNIT_FIELD_MINOFFHANDDAMAGE
Definition: UpdateFields.h:129
@ UNIT_CREATED_BY_SPELL
Definition: UpdateFields.h:138
@ PLAYER_FIELD_MAX_LEVEL
Definition: UpdateFields.h:384
@ UNIT_FIELD_BASEATTACKTIME
Definition: UpdateFields.h:120
@ PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
Definition: UpdateFields.h:367
@ UNIT_DYNAMIC_FLAGS
Definition: UpdateFields.h:136
@ ITEM_FIELD_DURABILITY
Definition: UpdateFields.h:69
@ ITEM_FIELD_DURATION
Definition: UpdateFields.h:40
@ ITEM_FIELD_FLAGS
Definition: UpdateFields.h:42
@ ITEM_FIELD_MAXDURABILITY
Definition: UpdateFields.h:70
@ ITEM_FIELD_CREATOR
Definition: UpdateFields.h:37
@ GAMEOBJECT_FACTION
Definition: UpdateFields.h:402
@ GAMEOBJECT_BYTES_1
Definition: UpdateFields.h:404
struct tm * localtime_r(time_t const *time, struct tm *result)
T AddPct(T &base, U pct)
Definition: Util.h:104
T ApplyPct(T &base, U pct)
Definition: Util.h:110
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:87
T CalculatePct(T base, U pct)
Definition: Util.h:98
phase
Definition: boss_skadi.cpp:101
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost=0)
void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete=false)
bool HasAchieved(uint32 achievementId) const
void CompletedAchievement(AchievementEntry const *entry)
void SendAllAchievementData() const
void CheckAllAchievementCriteria()
void SendRespondInspectAchievements(Player *player) const
void RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
void DelMember(ObjectGuid guid, bool cleanDb)
Definition: ArenaTeam.cpp:321
void BuildUpdatePacket(ByteBuffer &data, bool remove) const
Definition: SpellAuras.cpp:243
Aura * GetBase() const
AuraType GetAuraType() const
SpellInfo const * GetSpellInfo() const
int32 GetMiscValue() const
int32 GetAmount() const
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:105
uint32 GetId() const
Definition: SpellAuras.cpp:461
bool IsUsingCharges() const
Definition: SpellAuras.h:199
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:100
uint8 GetCharges() const
Definition: SpellAuras.h:140
bool IsPassive() const
time_t GetApplyTime() const
Definition: SpellAuras.h:128
SpellInfo const * GetTriggeredByAuraSpellInfo() const
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.h:145
Definition: Bag.h:28
virtual void FillInitialWorldStates(WorldPacket &)=0
bool IsWarTime()
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:248
uint32 GetTypeId()
Definition: Battlefield.h:242
bool HaveSpectators()
Definition: Battleground.h:419
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:430
bool isArena() const
Definition: Battleground.h:425
uint32 GetStartTime() const
Definition: Battleground.h:365
bool isBattleground() const
Definition: Battleground.h:426
BattlegroundStatus GetStatus() const
Definition: Battleground.h:363
BattlegroundMap * FindBgMap() const
Definition: Battleground.h:463
virtual void FillInitialWorldStates(WorldPacket &)
Definition: Battleground.h:479
uint32 GetMaxLevel() const
Definition: Battleground.h:370
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition: Battleground.h:361
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
void appendPackGUID(uint64 guid)
Definition: ByteBuffer.h:503
size_t wpos() const
Definition: ByteBuffer.h:330
void AppendPackedTime(time_t time)
Definition: ByteBuffer.cpp:137
void put(std::size_t pos, T value)
Definition: ByteBuffer.h:137
void LeaveChannel(Player *player, bool send=true)
Definition: Channel.cpp:252
std::string Name
User specified variables.
Definition: WorldSession.h:186
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:108
static size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition: Chat.cpp:197
Definition: Corpse.h:49
time_t const & GetGhostTime() const
Definition: Corpse.h:68
void SaveToDB()
Definition: Corpse.cpp:92
void ResetGhostTime()
Definition: Corpse.h:69
bool Create(ObjectGuid::LowType guidlow)
Definition: Corpse.cpp:63
Player * lootRecipient
Definition: Corpse.h:76
void RemoveFromWorld() override
Definition: Corpse.cpp:54
Loot loot
Definition: Corpse.h:75
CorpseType GetType() const
Definition: Corpse.h:70
void DeleteFromDB(CharacterDatabaseTransaction trans)
Definition: Corpse.cpp:121
Loot loot
Definition: Creature.h:211
VendorItemData const * GetVendorItems() const
Definition: Creature.cpp:2755
bool IsReputationGainDisabled() const
Definition: Creature.h:340
uint32 m_spells[MAX_CREATURE_SPELLS]
Definition: Creature.h:235
void SetLootRecipient(Unit *unit, bool withGroup=true)
Definition: Creature.cpp:1161
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:318
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:323
ObjectGuid GetLootRecipientGUID() const
Definition: Creature.h:212
CreatureSpellCooldowns m_CreatureSpellCooldowns
Definition: Creature.h:236
void SetPickPocketLootTime()
Definition: Creature.h:219
bool hasLootRecipient() const
Definition: Creature.h:216
Player * GetLootRecipient() const
Definition: Creature.cpp:1147
bool CanGeneratePickPocketLoot() const
Definition: Creature.h:218
uint32 UpdateVendorItemCurrentCount(VendorItem const *vItem, uint32 used_count)
Definition: Creature.cpp:2795
uint32 GetVendorItemCurrentCount(VendorItem const *vItem)
Definition: Creature.cpp:2760
Group * GetLootRecipientGroup() const
Definition: Creature.cpp:1154
ReactStates GetReactState() const
Definition: Creature.h:84
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:190
bool IsRacialLeader() const
Definition: Creature.h:73
uint32 GetResist() const
Definition: Unit.h:934
uint32 GetDamage() const
Definition: Unit.h:932
uint32 GetAbsorb() const
Definition: Unit.h:933
Class used to access individual fields of database query result.
Definition: Field.h:84
uint8 GetUInt8() const
Definition: Field.cpp:33
std::string GetString() const
Definition: Field.cpp:228
uint16 GetUInt16() const
Definition: Field.cpp:69
float GetFloat() const
Definition: Field.cpp:177
bool GetBool() const
Definition: Field.h:92
uint32 GetUInt32() const
Definition: Field.cpp:105
void AddFlag(FLAG_TYPE flag)
Definition: Object.h:632
void DelFlag(FLAG_TYPE flag)
Definition: Object.h:633
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:636
uint32 GetRespawnDelay() const
Definition: GameObject.h:825
bool IsWithinDistInMap(Player const *player) const
LootState getLootState() const
Definition: GameObject.h:846
bool isSpawnedByDefault() const
Definition: GameObject.h:823
time_t GetRespawnTime() const
Definition: GameObject.h:804
uint32 GetLootGenerationTime() const
Definition: GameObject.h:888
void SetLootState(LootState s, Unit *unit=nullptr)
void GetFishLootJunk(Loot *loot, Player *loot_owner)
Definition: GameObject.cpp:932
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:794
GameobjectTypes GetGoType() const
Definition: GameObject.h:831
void GetFishLoot(Loot *loot, Player *loot_owner)
Definition: GameObject.cpp:912
GameObjectTemplateAddon const * GetTemplateAddon() const
Definition: GameObject.cpp:822
void SetLootGenerationTime()
Definition: GameObject.h:887
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:757
uint16 GetLootMode() const
Definition: GameObject.h:850
uint32 GetId() const
Definition: TicketMgr.h:100
Definition: Group.h:167
void NeedBeforeGreed(Loot *loot, WorldObject *pLootedObject)
Definition: Group.cpp:1104
ObjectGuid GetMasterLooterGuid() const
Definition: Group.cpp:2177
bool isLFGGroup(bool restricted=false) const
Definition: Group.cpp:2126
bool IsCreated() const
Definition: Group.cpp:2147
GroupReference * GetFirstMember()
Definition: Group.h:239
void RemoveAllInvites()
Definition: Group.cpp:346
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2206
bool isRollLootActive() const
Definition: Group.cpp:2309
void GroupLoot(Loot *loot, WorldObject *pLootedObject)
Definition: Group.cpp:954
void Disband(bool hideDestroy=false)
Definition: Group.cpp:732
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2192
ObjectGuid GetGUID() const
Definition: Group.cpp:2157
void RemoveInvite(Player *player)
Definition: Group.cpp:336
uint32 GetMembersCount() const
Definition: Group.h:241
bool RemoveMember(ObjectGuid guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Group.cpp:528
LootMethod GetLootMethod() const
Definition: Group.cpp:2167
void UpdateLooterGuid(WorldObject *pLootedObject, bool ifneed=false)
Definition: Group.cpp:1780
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Definition: Group.cpp:2214
void MasterLoot(Loot *loot, WorldObject *pLootedObject)
Definition: Group.cpp:1246
GroupReference * next()
void setSubGroup(uint8 pSubGroup)
Definition: Guild.h:282
bool HandleMemberWithdrawMoney(WorldSession *session, uint32 amount, bool repair=false)
Definition: Guild.cpp:1738
void setOnlineOfflineState(bool isOnline)
void updateThreatTables()
time_t GetExtendedResetTime() const
time_t GetResetTime() const
virtual void FillInitialWorldStates(WorldPacket &)
Definition: Item.h:214
uint32 GetPlayedTime()
Definition: Item.cpp:1209
static void DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:495
void SetState(ItemUpdateState state, Player *forplayer=nullptr)
Definition: Item.cpp:677
uint8 GetSlot() const
Definition: Item.h:272
bool HasSocket() const
Definition: Item.cpp:970
virtual void SaveToDB(CharacterDatabaseTransaction trans)
Definition: Item.cpp:314
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:295
uint32 GetPaidExtendedCost()
Definition: Item.h:340
uint32 GetPaidMoney()
Definition: Item.h:339
void SetPaidMoney(uint32 money)
Definition: Item.h:336
ObjectGuid::LowType GetRefundRecipient()
Definition: Item.h:338
int32 GetItemRandomPropertyId() const
Definition: Item.h:286
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:507
void SaveRefundDataToDB()
Definition: Item.cpp:1135
void SetNotRefundable(Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
Definition: Item.cpp:1163
bool IsBroken() const
Definition: Item.h:251
uint32 GetItemSuffixFactor() const
Definition: Item.h:287
bool IsEquipped() const
Definition: Item.cpp:752
void SendTimeUpdate(Player *owner)
Definition: Item.cpp:1038
void SetRefundRecipient(ObjectGuid::LowType pGuidLow)
Definition: Item.h:335
bool IsRefundExpired()
Definition: Item.cpp:1216
void UpdatePlayedTime(Player *owner)
Definition: Item.cpp:1181
uint32 GetSkill()
Definition: Item.cpp:518
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
Definition: Item.cpp:914
void ClearEnchantment(EnchantmentSlot slot)
Definition: Item.cpp:923
void SetPaidExtendedCost(uint32 iece)
Definition: Item.h:337
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:297
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const
Definition: Item.cpp:996
bool m_lootGenerated
Definition: Item.h:312
Loot loot
Definition: Item.h:311
uint8 GetBagSlot() const
Definition: Item.cpp:747
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition: Item.cpp:847
bool operator()(const SpellModifier *a, const SpellModifier *b) const
Definition: Player.cpp:9175
void SendMailTo(CharacterDatabaseTransaction trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0, uint32 custom_expiration=0, bool deleteMailItemsFromDB=false, bool sendMail=true, int32 auctionId=0)
Definition: Mail.cpp:181
MailDraft & AddMoney(uint32 money)
Definition: Mail.h:136
void SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, CharacterDatabaseTransaction trans)
Definition: Mail.cpp:143
MailDraft & AddItem(Item *item)
Definition: Mail.cpp:92
Definition: Map.h:299
bool IsDungeon() const
Definition: Map.h:434
bool IsBattlegroundOrArena() const
Definition: Map.h:442
virtual void RemovePlayerFromMap(Player *, bool)
Definition: Map.cpp:903
bool IsNonRaidDungeon() const
Definition: Map.h:435
void AddCorpse(Corpse *corpse)
Definition: Map.cpp:3536
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition: Map.h:517
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Map.cpp:3258
Creature * GetCreature(ObjectGuid const guid)
Definition: Map.cpp:3253
void UpdateIteratorBack(Player *player)
Definition: Map.cpp:3282
uint32 GetId() const
Definition: Map.h:365
Difficulty GetDifficulty() const
Definition: Map.h:429
Corpse * ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia=false)
Definition: Map.cpp:3567
bool AddToMap(T *, bool checkTransport=false)
Definition: Map.cpp:546
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:91
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
void MoveFall(uint32 id=0, bool addFlagForNPC=false)
PackedGuid WriteAsPacked() const
Definition: ObjectGuid.h:318
LowType GetCounter() const
Definition: ObjectGuid.h:147
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
bool IsCorpse() const
Definition: ObjectGuid.h:175
bool IsMOTransport() const
Definition: ObjectGuid.h:177
bool IsItem() const
Definition: ObjectGuid.h:172
std::string ToString() const
Definition: ObjectGuid.cpp:47
bool IsGameObject() const
Definition: ObjectGuid.h:173
uint32 LowType
Definition: ObjectGuid.h:124
void Clear()
Definition: ObjectGuid.h:140
Definition: Object.h:89
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:129
void UpdateUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:654
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:741
uint16 m_objectType
Definition: Object.h:212
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:628
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
bool IsInWorld() const
Definition: Object.h:93
uint16 GetUInt16Value(uint16 index, uint8 offset) const
Definition: Object.cpp:325
virtual void DestroyForPlayer(Player *target, bool onDeath=false) const
Definition: Object.cpp:269
Creature * ToCreature()
Definition: Object.h:183
bool AddGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:677
TypeID GetTypeId() const
Definition: Object.h:107
uint32 * m_uint32Values
Definition: Object.h:220
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:184
bool isType(uint16 mask) const
Definition: Object.h:108
uint16 m_valuesCount
Definition: Object.h:226
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:836
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:851
void ApplyModUInt32Value(uint16 index, int32 val, bool apply)
Definition: Object.cpp:797
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
Definition: Object.cpp:890
void SetGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:714
void SetFlag64(uint16 index, uint64 newFlag)
Definition: Object.cpp:947
uint32 GetEntry() const
Definition: Object.h:101
uint64 GetUInt64Value(uint16 index) const
Definition: Object.cpp:306
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:728
bool RemoveGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:695
virtual void AddToWorld()
Definition: Object.cpp:147
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:921
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:880
virtual void RemoveFromWorld()
Definition: Object.cpp:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:98
PackedGuid const & GetPackGUID() const
Definition: Object.h:100
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.cpp:940
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:641
Player * ToPlayer()
Definition: Object.h:181
ObjectGuid GetGUID() const
Definition: Object.h:99
void ToggleFlag(uint16 index, uint32 flag)
Definition: Object.cpp:868
TypeID m_objectTypeId
Definition: Object.h:214
void SetUInt64Value(uint16 index, uint64 value)
Definition: Object.cpp:662
ObjectGuid GetGuidValue(uint16 index) const
Definition: Object.cpp:332
void ForceValuesUpdateAtIndex(uint32)
Definition: Object.cpp:2173
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:902
virtual void FillInitialWorldStates(WorldPacket &)
Definition: OutdoorPvP.h:204
uint32 GetTypeId()
Definition: OutdoorPvP.h:239
std::size_t size() const
Definition: ObjectGuid.h:276
Definition: Pet.h:55
uint32 m_usedTalentCount
Definition: Pet.h:156
uint8 GetFreeTalentPoints()
Definition: Pet.h:153
void SavePetToDB(PetSaveMode mode, bool logout)
Definition: Pet.cpp:239
PetType getPetType() const
Definition: Pet.h:65
bool IsPermanentPetFor(Player *owner) const
Definition: Pet.cpp:1984
static bool LoadPetFromDB(Player *owner, uint8 asynchLoadType, uint32 petentry=0, uint32 petnumber=0, bool current=false, AsynchPetSummon *info=nullptr)
Definition: Pet.cpp:173
bool isTemporarySummoned() const
Definition: Pet.h:68
int32 GetDuration() const
Definition: Pet.h:103
bool isControlled() const
Definition: Pet.h:67
bool m_removed
Definition: Pet.h:164
void SetFreeTalentPoints(uint8 points)
Definition: Pet.h:154
bool HasSpell(uint32 spell) const override
Definition: Pet.cpp:2027
bool resetTalents()
Definition: Pet.cpp:1746
PetSpellMap m_spells
Definition: Pet.h:143
void DeleteFromDB() override
Definition: Pet.h:195
bool learnSpell(uint32 spell_id)
Definition: Pet.cpp:1601
void SaveToDB(bool create, bool logout)
bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count)
Definition: Player.cpp:712
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const *newSkin=nullptr)
Definition: Player.cpp:12439
void AddNewMailDeliverTime(time_t deliver_time)
Definition: Player.cpp:2786
bool IsAtRecruitAFriendDistance(WorldObject const *pOther) const
Definition: Player.cpp:11993
void UpdateParryPercentage()
Definition: StatSystem.cpp:708
bool HasPendingSpectatorForBG(uint32 bgInstanceId) const
Definition: Player.h:2533
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool awardXP=true)
Definition: Player.cpp:5866
void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen)
Definition: Player.cpp:747
InstanceTimeMap _instanceResetTimes
Definition: Player.h:2924
std::string GetPlayerName()
Definition: Player.cpp:15408
void GetAurasForTarget(Unit *target)
Definition: Player.cpp:11353
bool m_canParry
Definition: Player.h:2816
ActionButton * addActionButton(uint8 button, uint32 action, uint8 type)
Definition: Player.cpp:5459
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
void CleanupChannels()
Definition: Player.cpp:4837
ItemMap mMitems
Definition: Player.h:1603
bool SetDisableGravity(bool disable, bool packetOnly) override
Definition: Player.cpp:14966
time_t m_summon_expire
Definition: Player.h:2849
void CheckAreaExploreAndOutdoor()
Definition: Player.cpp:5552
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
MapReference m_mapRef
Definition: Player.h:2891
uint16 m_additionalSaveTimer
Definition: Player.h:2719
static uint32 GetUInt32ValueFromArray(Tokenizer const &data, uint16 index)
ReputationMgr & GetReputationMgr()
Definition: Player.h:2067
void SendInitialPacketsAfterAddToMap()
Definition: Player.cpp:10922
void ResetSeasonalQuestStatus(uint16 event_id)
Definition: Player.cpp:11469
uint32 m_resurrectMana
Definition: Player.h:2787
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5634
void ActivateSpec(uint8 spec)
Definition: Player.cpp:14207
void SendTeleportAckPacket()
Definition: Player.cpp:1291
float m_ammoDPS
Definition: Player.h:2820
float GetQuestRate()
Definition: Player.cpp:15359
void SendExplorationExperience(uint32 Area, uint32 Experience)
Definition: PlayerMisc.cpp:157
GroupReference m_originalGroup
Definition: Player.h:2839
static bool IsEquipmentPos(uint16 pos)
Definition: Player.h:1202
const PlayerTalentMap & GetTalentMap() const
Definition: Player.h:2566
PlayerSpellMap m_spells
Definition: Player.h:2754
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Player.cpp:2278
float GetMeleeCritFromAgility()
Definition: Player.cpp:4930
Difficulty GetRaidDifficulty() const
Definition: Player.h:1864
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:9375
void _ApplyAllLevelScaleItemMods(bool apply)
Definition: Player.cpp:7365
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const *pProto, Creature *pVendor, VendorItem const *crItem, bool bStore)
Definition: Player.cpp:9911
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const &store, bool broadcast=false)
Definition: Player.cpp:12677
void RemoveAtLoginFlag(AtLoginFlags flags, bool persist=false)
Definition: Player.cpp:13774
void _removeTalent(PlayerTalentMap::iterator &itr, uint8 specMask)
Definition: Player.cpp:2866
void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError=0, ObjectGuid::LowType item_guid=0, uint32 item_count=0)
Definition: Player.cpp:2762
uint32 m_temporaryUnsummonedPetNumber
Definition: Player.h:2914
bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const
Definition: Player.cpp:12668
void SendCinematicStart(uint32 CinematicSequenceId)
Definition: Player.cpp:5534
QuestStatusMap m_QuestStatus
Definition: Player.h:2741
uint32 m_ChampioningFaction
Definition: Player.h:2922
void RemoveRunesByAuraEffect(AuraEffect const *aura)
Definition: Player.cpp:12574
bool NeedSendSpectatorData() const
Definition: Player.cpp:14524
bool m_bHasDelayedTeleport
Definition: Player.h:2911
void ScheduleDelayedOperation(uint32 operation)
Definition: Player.h:2041
bool m_InstanceValid
Definition: Player.h:2399
void removeActionButton(uint8 button)
Definition: Player.cpp:5474
bool _addSpell(uint32 spellId, uint8 addSpecMask, bool temporary, bool learnFromSkill=false)
Definition: Player.cpp:2994
static void OfflineResurrect(ObjectGuid const guid, CharacterDatabaseTransaction trans)
Definition: Player.cpp:4423
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost=0)
Definition: Player.cpp:13091
static uint32 GetLevelFromStorage(ObjectGuid::LowType guid)
Definition: Player.cpp:6181
void HandleFall(MovementInfo const &movementInfo)
Definition: Player.cpp:13018
void SendInitialSpells()
Definition: Player.cpp:2653
time_t m_deathExpireTime
Definition: Player.h:2812
int32 GetQuestLevel(Quest const *quest) const
Definition: Player.h:1359
uint8 GetChatTag() const
Definition: Player.cpp:1275
void SendTalentsInfoData(bool pet)
Definition: Player.cpp:13552
void RemoveItemDependentAurasAndCasts(Item *pItem)
Definition: Player.cpp:11775
void SetOriginalGroup(Group *group, int8 subgroup=-1)
Definition: Player.cpp:12302
void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask)
Definition: Player.cpp:9399
void removeSpell(uint32 spellId, uint8 removeSpecMask, bool onlyTemporary)
Definition: Player.cpp:3223
bool AddItem(uint32 itemId, uint32 count)
Definition: Player.cpp:14683
uint32 GetArenaPersonalRating(uint8 slot) const
Definition: Player.cpp:15314
bool IsInSameRaidWith(Player const *p) const
Definition: Player.h:1825
void RemoveSpellMods(Spell *spell)
Definition: Player.cpp:9309
ReputationMgr * m_reputationMgr
Definition: Player.h:2918
float m_auraBaseMod[BASEMOD_END][MOD_END]
Definition: Player.h:2767
void LearnTalent(uint32 talentId, uint32 talentRank)
Definition: Player.cpp:13111
void ToggleMetaGemsActive(uint8 exceptslot, bool apply)
Definition: Player.cpp:10512
InventoryResult CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading=true) const
void RewardExtraBonusTalentPoints(uint32 bonusTalentPoints)
Definition: Player.cpp:5855
void learnSpell(uint32 spellId, bool temporary=false, bool learnFromSkill=false)
Definition: Player.cpp:3182
bool HasQuestForGO(int32 GOId) const
Definition: Player.cpp:11585
bool HasTankSpec()
Definition: Player.cpp:15199
void InitPrimaryProfessions()
Definition: Player.cpp:10728
static uint32 GetArenaTeamIdFromStorage(ObjectGuid::LowType guid, uint8 slot)
Definition: Player.cpp:6103
void InitTalentForLevel()
Definition: Player.cpp:2477
PlayerSpellMap const & GetSpellMap() const
Definition: Player.h:1705
bool HasItemFitToSpellRequirements(SpellInfo const *spellInfo, Item const *ignoreItem=nullptr) const
Definition: Player.cpp:11713
WorldSession * GetSession() const
Definition: Player.h:1940
void SendMessageToSetInRange_OwnTeam(WorldPacket *data, float dist, bool self)
Definition: Player.cpp:5520
float m_homebindZ
Definition: Player.h:2338
void SendCorpseReclaimDelay(uint32 delay)
Definition: Player.cpp:12167
void SendRemoveControlBar()
Definition: Player.cpp:9128
static void DeleteOldCharacters()
Definition: Player.cpp:4204
void _LoadGlyphs(PreparedQueryResult result)
Definition: Player.cpp:14092
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap)
Definition: Player.cpp:11023
bool addTalent(uint32 spellId, uint8 addSpecMask, uint8 oldTalentRank)
Definition: Player.cpp:2802
uint32 GetGuildId() const
Definition: Player.h:1840
InventoryResult CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, bool swap) const
static uint32 GetZoneIdFromDB(ObjectGuid guid)
Definition: Player.cpp:6130
void SetRestFlag(RestFlag restFlag, uint32 triggerId=0)
Definition: Player.cpp:15281
void SummonIfPossible(bool agree, ObjectGuid summoner_guid)
Definition: Player.cpp:11621
void SetFarSightDistance(float radius)
Definition: Player.cpp:15382
uint32 m_lastFallTime
Definition: Player.h:2895
void InitGlyphsForLevel()
Definition: Player.cpp:12476
ItemDurationList m_itemDuration
Definition: Player.h:2780
void _removeTalentAurasAndSpells(uint32 spellId)
Definition: Player.cpp:2888
uint32 m_lastPotionId
Definition: Player.h:2756
void GiveLevel(uint8 level)
Definition: Player.cpp:2375
void BuildPetTalentsInfoData(WorldPacket *data)
Definition: Player.cpp:13480
void SendUpdateToOutOfRangeGroupMembers()
Definition: Player.cpp:10991
void UpdateShieldBlockValue()
Definition: StatSystem.cpp:522
uint32 GetFreeTalentPoints() const
Definition: Player.h:1651
bool IsInWhisperWhiteList(ObjectGuid guid)
Definition: Player.cpp:14957
void UpdateMaxPower(Powers power) override
Definition: StatSystem.cpp:302
void Regenerate(Powers power)
Definition: Player.cpp:1799
void SetGroupUpdateFlag(uint32 flag)
Definition: Player.h:2437
uint32 m_usedTalentCount
Definition: Player.h:2830
Bag * GetBagByPos(uint8 slot) const
void _ApplyAmmoBonuses()
Definition: Player.cpp:7383
void AddRefundReference(ObjectGuid itemGUID)
Definition: Player.cpp:14631
bool isUsingLfg()
Definition: Player.cpp:12258
void SetServerSideVisibility(ServerSideVisibilityType type, AccountTypes sec)
Definition: Player.cpp:15368
uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
Definition: Player.cpp:779
void ApplyItemEquipSpell(Item *item, bool apply, bool form_change=false)
Definition: Player.cpp:6869
uint32 GetArenaPoints() const
Definition: Player.h:2095
void SetGameMaster(bool on)
Definition: Player.cpp:2146
void KillPlayer()
Definition: Player.cpp:4392
void EndCinematic()
Definition: Player.cpp:15095
std::string autoReplyMsg
Definition: Player.h:1096
void ApplyRatingMod(CombatRating cr, int32 value, bool apply)
Definition: Player.cpp:5094
void ResetContestedPvP()
Definition: Player.h:1809
bool m_MonthlyQuestChanged
Definition: Player.h:2800
void LearnCustomSpells()
Definition: Player.cpp:11124
void DuelComplete(DuelCompleteType type)
Definition: Player.cpp:6230
void UpdateVisibilityForPlayer(bool mapChange=false)
void UpdateCritPercentage(WeaponAttackType attType)
Definition: StatSystem.cpp:620
uint8 GetDrunkValue() const
Definition: Player.h:2113
FlyByCameraCollection * m_cinematicCamera
Definition: Player.h:2942
void SetRuneCooldown(uint8 index, uint32 cooldown)
Definition: Player.h:2474
PlayerSocial * m_social
Definition: Player.h:2835
SkillStatusMap mSkillStatus
Definition: Player.h:2748
float GetAverageItemLevelForDF()
Definition: Player.cpp:14859
void RestoreSpellMods(Spell *spell, uint32 ownerAuraId=0, Aura *aura=nullptr)
Definition: Player.cpp:9235
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5287
uint32 m_homebindMapId
Definition: Player.h:2334
WorldLocation _corpseLocation
Definition: Player.h:2946
void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
Definition: Player.cpp:6967
void SetInWater(bool apply)
Definition: Player.cpp:2104
void SetAcceptWhispers(bool on)
Definition: Player.h:1113
float m_summon_z
Definition: Player.h:2853
void DestroyForPlayer(Player *target, bool onDeath=false) const override
Definition: Player.cpp:3739
uint32 m_speakCount
Definition: Player.h:2723
time_t m_lastHonorUpdateTime
Definition: Player.h:2712
time_t _restTime
Definition: Player.h:2823
InventoryResult CanEquipUniqueItem(Item *pItem, uint8 except_slot=NULL_SLOT, uint32 limit_count=1) const
Definition: Player.cpp:12955
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override
Definition: Player.cpp:9805
ObjectGuid m_comboTarget
Definition: Player.h:2738
void UpdateSkillsToMaxSkillsForLevel()
bool HasMeleeSpec()
Definition: Player.cpp:15217
SafeUnitPointer m_mover
Definition: Player.h:2298
void SendBGWeekendWorldStates()
Definition: Player.cpp:8568
void _SaveTalents(CharacterDatabaseTransaction trans)
Definition: Player.cpp:14162
bool addSpell(uint32 spellId, uint8 addSpecMask, bool updateActive, bool temporary=false, bool learnFromSkill=false)
Definition: Player.cpp:2947
void SendTalentWipeConfirm(ObjectGuid guid)
Definition: Player.cpp:8621
void BuildEnchantmentsInfoData(WorldPacket *data)
Definition: Player.cpp:13563
void SetCanParry(bool value)
Definition: Player.cpp:12315
uint8 m_forced_speed_changes[MAX_MOVE_TYPE]
Definition: Player.h:2365
float GetRatingBonusValue(CombatRating cr) const
Definition: Player.cpp:5033
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5529
uint32 _activeCheats
Definition: Player.h:2928
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap=false) const
Definition: Player.h:1222
void CharmSpellInitialize()
Definition: Player.cpp:9074
void SetCanTitanGrip(bool value)
Definition: Player.cpp:12333
float m_resurrectZ
Definition: Player.h:2786
void SaveInventoryAndGoldToDB(CharacterDatabaseTransaction trans)
void ClearComboPoints()
Definition: Player.cpp:10832
void LearnDefaultSkill(uint32 skillId, uint16 rank)
Definition: Player.cpp:11164
uint32 m_resetTalentsCost
Definition: Player.h:2828
void SetArenaPoints(uint32 value)
Definition: Player.cpp:6048
Group * GetGroup()
Definition: Player.h:2431
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
Definition: Player.cpp:15308
uint8 m_MirrorTimerFlags
Definition: Player.h:2899
void SendLootRelease(ObjectGuid guid)
Definition: Player.cpp:7520
uint32 m_atLoginFlags
Definition: Player.h:2728
bool canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const *bySpell) const
Definition: Player.cpp:12819
void GetDodgeFromAgility(float &diminishing, float &nondiminishing)
Definition: Player.cpp:4947
void SetGroup(Group *group, int8 subgroup=-1)
Definition: Player.cpp:10850
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Player.cpp:471
void SetRestBonus(float rest_bonus_new)
Definition: Player.cpp:9497
uint32 m_ExtraFlags
Definition: Player.h:2736
float m_recallX
Definition: Player.h:2325
float GetTotalBaseModValue(BaseModGroup modGroup) const
Definition: Player.cpp:4907
bool isBeingLoaded() const override
static uint32 GetGuildIdFromStorage(ObjectGuid::LowType guid)
Definition: Player.cpp:6089
DFQuestsDoneList m_DFQuests
Definition: Player.h:2375
uint32 GetMountBlockId()
Definition: Player.h:2560
void SetActiveSpec(uint8 spec)
Definition: Player.h:1675
void DurabilityLossAll(double percent, bool inventory)
Definition: Player.cpp:4550
void UpdateBlockPercentage()
Definition: StatSystem.cpp:601
bool CanUseBattlegroundObject(GameObject *gameobject) const
Definition: Player.cpp:12412
void GetTalentTreePoints(uint8(&specPoints)[3]) const
Definition: Player.cpp:14417
uint32 m_ingametime
Definition: Player.h:2644
float m_recallO
Definition: Player.h:2328
bool m_WeeklyQuestChanged
Definition: Player.h:2799
Group * GetOriginalGroup()
Definition: Player.h:2446
void SetEntryPoint()
Definition: Player.cpp:10545
uint32 GetTotalPlayedTime()
Definition: Player.h:1140
bool ModifyMoney(int32 amount, bool sendError=true)
Definition: Player.cpp:10733
bool InBattleground() const
Definition: Player.h:2190
void SendLearnPacket(uint32 spellId, bool learn)
Definition: Player.cpp:2930
void ApplySpellPenetrationBonus(int32 amount, bool apply)
Definition: StatSystem.cpp:212
uint32 GetXPRestBonus(uint32 xp)
Definition: Player.cpp:8601
void DurabilityPointLossForEquipSlot(EquipmentSlots slot)
Definition: Player.cpp:4652
void GiveXP(uint32 xp, Unit *victim, float group_rate=1.0f)
Definition: Player.cpp:2306
uint8 unReadMails
Definition: Player.h:1598
uint32 GetRuneBaseCooldown(uint8 index, bool skipGrace)
Definition: Player.cpp:12557
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2050
void CompletedAchievement(AchievementEntry const *entry)
Definition: Player.cpp:13106
bool inRandomLfgDungeon()
Definition: Player.cpp:12263
void SetRegularAttackTime()
Definition: Player.cpp:5128
uint32 m_pendingSpectatorInviteInstanceId
Definition: Player.h:2541
void SetBaseRune(uint8 index, RuneType baseRune)
Definition: Player.h:2472
void SetGroupInvite(Group *group)
Definition: Player.h:2430
uint32 m_DelayedOperations
Definition: Player.h:2909
void _LoadTalents(PreparedQueryResult result)
Definition: Player.cpp:14141
uint32 GetGlyph(uint8 slot) const
Definition: Player.h:1699
void SpawnCorpseBones(bool triggerSave=true)
Definition: Player.cpp:4525
void UpdateZone(uint32 newZone, uint32 newArea)
void SetDrunkValue(uint8 newDrunkValue, uint32 itemId=0)
Definition: Player.cpp:996
void SetMonthlyQuestStatus(uint32 quest_id)
Definition: Player.cpp:11441
void RemoveMail(uint32 id)
Definition: Player.cpp:2749
bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot=NULL_SLOT) const
bool IsSpellFitByClassAndRace(uint32 spell_id) const
Definition: Player.cpp:11560
float GetReputationPriceDiscount(Creature const *creature) const
Definition: Player.cpp:11547
bool SetCanFly(bool apply, bool packetOnly=false) override
Definition: Player.cpp:14983
EquipmentSets m_EquipmentSets
Definition: Player.h:2858
bool IsInAreaTriggerRadius(const AreaTrigger *trigger) const
Definition: Player.cpp:2122
Difficulty GetDifficulty(bool isRaid) const
Definition: Player.h:1862
void RemoveFromBattlegroundOrBattlefieldRaid()
Definition: Player.cpp:12290
bool IsPetNeedBeTemporaryUnsummoned() const
Definition: Player.h:2382
void LoadActions(PreparedQueryResult result)
Definition: Player.cpp:14409
void PetSpellInitialize()
Definition: Player.cpp:8899
QuestSet m_weeklyquests
Definition: Player.h:2639
QuestGiverStatus GetQuestDialogStatus(Object *questGiver)
void SetSeasonalQuestStatus(uint32 quest_id)
Definition: Player.cpp:11431
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition: Player.h:1190
void DropModCharge(SpellModifier *mod, Spell *spell)
Definition: Player.cpp:9359
void UpdateEquipSpellsAtFormChange()
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2346
void ContinueTaxiFlight()
Definition: Player.cpp:9745
void _SaveCharacter(bool create, CharacterDatabaseTransaction trans)
Definition: Player.cpp:13818
void SetFallInformation(uint32 time, float z)
Definition: Player.h:2301
void SendInitialPacketsBeforeAddToMap()
Definition: Player.cpp:10865
bool CanSeeDKPet() const
Definition: Player.h:2549
TradeData * m_trade
Definition: Player.h:2796
float m_realParry
Definition: Player.h:2606
static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
Definition: Player.cpp:3866
void ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur=true, bool ignore_condition=false)
void UpdateVisibilityOf(WorldObject *target)
QuestSet m_monthlyquests
Definition: Player.h:2640
Item * EquipNewItem(uint16 pos, uint32 item, bool update)
void SetLootGUID(ObjectGuid guid)
Definition: Player.h:1936
bool HasPendingBind() const
Definition: Player.h:2402
uint32 m_nextSave
Definition: Player.h:2718
void ResetMap() override
Definition: Player.cpp:13800
void ResurectUsingRequestData()
Definition: Player.cpp:12020
SpellModList m_spellMods[MAX_SPELLMOD]
Definition: Player.h:2775
void RemoveRestState()
Definition: Player.cpp:1095
uint32 m_zoneUpdateTimer
Definition: Player.h:2808
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=nullptr, uint32 spellid=1)
Definition: Player.cpp:9528
bool HasActiveSpell(uint32 spell) const
Definition: Player.cpp:3782
void ResetMonthlyQuestStatus()
Definition: Player.cpp:11479
bool m_mailsUpdated
Definition: Player.h:1527
void SendNewMail()
Definition: Player.cpp:2778
uint16 GetMaxSkillValueForLevel() const
Definition: Player.cpp:15350
void ResetDailyQuestStatus()
Definition: Player.cpp:11447
time_t mSemaphoreTeleport_Far
Definition: Player.h:2907
float _restBonus
Definition: Player.h:2825
GameObject * GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const
Definition: Player.cpp:2080
bool IsPetDismissed()
Definition: Player.cpp:15126
bool SetHover(bool enable, bool packetOnly=false) override
Definition: Player.cpp:15005
uint32 m_foodEmoteTimerCount
Definition: Player.h:2612
bool IsNeedCastPassiveSpellAtLearn(SpellInfo const *spellInfo) const
Definition: Player.cpp:3173
void SetGlyphSlot(uint8 slot, uint32 slottype)
Definition: Player.h:1689
void SetObjectScale(float scale) override
Definition: Player.h:1037
Pet * GetPet() const
Definition: Player.cpp:8649
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:11489
void UpdateLootAchievements(LootItem *item, Loot *loot)
void DeleteRefundReference(ObjectGuid itemGUID)
Definition: Player.cpp:14636
uint32 m_baseFeralAP
Definition: Player.h:2770
Position m_remoteSightPosition
Definition: Player.h:2943
void ResyncRunes(uint8 count)
Definition: Player.cpp:12615
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:11957
bool CanTitanGrip() const
Definition: Player.h:2127
bool TeleportToEntryPoint()
Definition: Player.cpp:1563
void SetCurrentTitle(CharTitlesEntry const *title, bool clear=false)
Definition: Player.h:2498
void _RemoveAllItemMods()
Definition: Player.cpp:7268
bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
Definition: Player.cpp:9977
bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot=NULL_SLOT) const
void InitDisplayIds()
Definition: Player.cpp:9885
void SetRestState(uint32 triggerId)
Definition: Player.cpp:1088
float m_summon_y
Definition: Player.h:2852
uint32 GetResurrectionSpellId()
Definition: Player.cpp:11807
WorldObject * m_seer
Definition: Player.h:2299
bool HasTitle(uint32 bitIndex) const
Definition: Player.cpp:12515
void SendUpdateWorldState(uint32 Field, uint32 Value)
float m_summon_x
Definition: Player.h:2851
void _ApplyItemBonuses(ItemTemplate const *proto, uint8 slot, bool apply, bool only_level_scale=false)
Definition: Player.cpp:6380
uint32 m_charmAISpells[NUM_CAI_SPELLS]
Definition: Player.h:2608
uint8 m_additionalSaveMask
Definition: Player.h:2720
void _LoadBrewOfTheMonth(PreparedQueryResult result)
Definition: Player.cpp:14897
bool m_bMustDelayTeleport
Definition: Player.h:2910
bool m_SeasonalQuestChanged
Definition: Player.h:2801
uint32 GetLastPetSpell() const
Definition: Player.h:2422
void RegenerateHealth()
Definition: Player.cpp:1936
uint16 GetPureSkillValue(uint32 skill) const
Definition: Player.cpp:5352
bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo *createInfo)
Definition: Player.cpp:479
void SendDuelCountdown(uint32 counter)
Definition: Player.cpp:14483
bool IsTwoHandUsed() const
Definition: Player.h:1301
TeamId m_team
Definition: Player.h:2717
void _ApplyAllItemMods()
Definition: Player.cpp:7316
void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, AuraEffect const *aura, bool apply)
Definition: Player.cpp:6813
uint32 m_areaUpdateId
Definition: Player.h:2809
bool HasAchieved(uint32 achievementId) const
Definition: Player.cpp:13086
bool HasTalent(uint32 spell_id, uint8 spec) const
Definition: Player.cpp:3776
void SetCanBlock(bool value)
Definition: Player.cpp:12324
uint8 m_specsCount
Definition: Player.h:2761
int8 m_comboPointGain
Definition: Player.h:2599
bool GetCommandStatus(uint32 command) const
Definition: Player.h:1132
int16 GetSkillTempBonusValue(uint32 skill) const
Definition: Player.cpp:5376
bool CheckAmmoCompatibility(const ItemTemplate *ammo_proto) const
Definition: Player.cpp:7409
uint32 m_extraBonusTalentCount
Definition: Player.h:2832
MapReference & GetMapRef()
Definition: Player.h:2454
void RestoreBaseRune(uint8 index)
Definition: Player.cpp:12586
int16 GetSkillPermBonusValue(uint32 skill) const
Definition: Player.cpp:5364
Item * StoreItem(ItemPosCountVec const &pos, Item *pItem, bool update)
void DeleteEquipmentSet(uint64 setGuid)
Definition: Player.cpp:13759
OutdoorPvP * GetOutdoorPvP() const
Definition: Player.cpp:11708
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Player.h:1721
GroupReference m_group
Definition: Player.h:2838
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition: Player.cpp:11507
void RemoveRestFlag(RestFlag restFlag)
Definition: Player.cpp:15296
void _ApplyWeaponDamage(uint8 slot, ItemTemplate const *proto, ScalingStatValuesEntry const *ssv, bool apply)
Definition: Player.cpp:6683
void SetServerSideVisibilityDetect(ServerSideVisibilityType type, AccountTypes sec)
Definition: Player.cpp:15375
void SetGracePeriod(uint8 index, uint32 period)
Definition: Player.h:2475
Item * GetItemByPos(uint16 pos) const
Guild * GetGuild() const
Definition: Player.cpp:15110
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5266
void _ApplyAllStatBonuses()
Definition: StatSystem.cpp:942
InventoryResult CanUseAmmo(uint32 item) const
bool IsNeverVisible() const override
Definition: Player.cpp:10668
void SetViewpoint(WorldObject *target, bool apply)
Definition: Player.cpp:12359
void StopMirrorTimers()
Definition: Player.h:1997
JoinedChannelsList m_channels
Definition: Player.h:2792
bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot)
Definition: Player.cpp:10383
void UnsummonPetTemporaryIfAny()
Definition: Player.cpp:13371
void _LoadRandomBGStatus(PreparedQueryResult result)
Definition: Player.cpp:14832
uint32 GetMailSize()
Definition: Player.h:1587
float m_powerFraction[MAX_POWERS]
Definition: Player.h:2613
uint32 m_oldpetspell
Definition: Player.h:2915
void CheckDuelDistance(time_t currTime)
Definition: Player.cpp:6191
Runes * m_runes
Definition: Player.h:2857
uint32 m_currentBuybackSlot
Definition: Player.h:2731
bool isTotalImmune() const
Definition: Player.cpp:12501
void ResetPetTalents()
Definition: Player.cpp:8630
bool GetsRecruitAFriendBonus(bool forXP)
Definition: Player.cpp:11883
ObjectGuid GetLootGUID() const
Definition: Player.h:1935
void SaveRecallPosition()
Definition: Player.cpp:5497
void ResetFarSightDistance()
Definition: Player.cpp:15387
BattlegroundQueueTypeId m_bgBattlegroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES]
Definition: Player.h:2620
uint32 m_deathTimer
Definition: Player.h:2811
uint32 m_regenTimerCount
Definition: Player.h:2611
uint32 m_resurrectHealth
Definition: Player.h:2787
void RepopAtGraveyard()
Definition: Player.cpp:4754
void SetAmmo(uint32 item)
float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const
Definition: Player.cpp:4893
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const override
Definition: Player.cpp:3708
uint16 GetMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5304
bool HasEnoughMoney(uint32 amount) const
Definition: Player.h:1541
float GetSightRange(const WorldObject *target=nullptr) const override
Definition: Player.cpp:15397
uint32 GetQuestSlotQuestId(uint16 slot) const
Definition: Player.h:1417
static uint32 GetArenaTeamIdFromDB(ObjectGuid guid, uint8 slot)
Definition: Player.cpp:6116
AchievementMgr * m_achievementMgr
Definition: Player.h:2917
void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, AuraEffect const *aura, bool apply)
Definition: Player.cpp:6780
void RemoveCorpse()
Definition: Player.cpp:4513
uint8 m_swingErrorMsg
Definition: Player.h:2819
bool CanAlwaysSee(WorldObject const *obj) const override
Definition: Player.cpp:10679
void DestroyItem(uint8 bag, uint8 slot, bool update)
uint16 GetBaseSkillValue(uint32 skill) const
Definition: Player.cpp:5338
time_t m_nextMailDelivereTime
Definition: Player.h:1599
uint16 GetSkillStep(uint16 skill) const
Definition: Player.cpp:5275
std::string const & GetGuildName()
Definition: Player.cpp:14478
void MoveItemFromInventory(uint8 bag, uint8 slot, bool update)
void RewardPlayerAndGroupAtKill(Unit *victim, bool isBattleGround)
Definition: Player.cpp:11924
void SetSelection(ObjectGuid guid)
Used for serverside target changes, does not apply to players.
Definition: Player.cpp:10773
uint32 GetHonorPoints() const
Definition: Player.h:2094
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool infinityCooldown=false)
Definition: Player.cpp:10176
void SendRespondInspectAchievements(Player *player) const
Definition: Player.cpp:13081
void clearResurrectRequestData()
Definition: Player.h:1766
static bool IsInventoryPos(uint16 pos)
Definition: Player.h:1200
bool HasHealSpec()
Definition: Player.cpp:15263
bool m_bPassOnGroupLoot
Definition: Player.h:2843
float m_recallZ
Definition: Player.h:2327
bool CanNoReagentCast(SpellInfo const *spellInfo) const
Definition: Player.cpp:11758
time_t m_speakTime
Definition: Player.h:2722
void SendBattlefieldWorldStates()
Definition: Player.cpp:8583
void SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime, uint32 createdBySpell, ObjectGuid casterGUID, uint8 asynchLoadType)
Definition: Player.cpp:15116
void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank)
Definition: Player.cpp:13230
uint16 GetPureMaxSkillValue(uint32 skill) const
Definition: Player.cpp:5322
void InitDataForForm(bool reapplyMods=false)
Definition: Player.cpp:9838
uint32 m_pendingSpectatorForBG
Definition: Player.h:2540
uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank)
Definition: Player.cpp:4658
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition: Player.cpp:5164
bool m_DailyQuestChanged
Definition: Player.h:2798
uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX]
Definition: Player.h:2763
static uint32 GetGroupIdFromStorage(ObjectGuid::LowType guid)
Definition: Player.cpp:6096
void StopCastingCharm()
Definition: Player.cpp:8747
void _SaveEquipmentSets(CharacterDatabaseTransaction trans)
Definition: Player.cpp:13677
Difficulty m_dungeonDifficulty
Definition: Player.h:2724
uint32 m_weaponChangeTimer
Definition: Player.h:2805
WorldObject * GetViewpoint() const
Definition: Player.cpp:12405
void AddComboPoints(Unit *target, int8 count)
Definition: Player.cpp:10800
uint32 m_WeaponProficiency
Definition: Player.h:2814
void SetCurrentRune(uint8 index, RuneType currentRune)
Definition: Player.h:2473
void UpdateCorpseReclaimDelay()
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
Definition: Player.cpp:8672
void learnSpellHighRank(uint32 spellid)
Definition: Player.cpp:12834
uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const
Definition: Player.cpp:12007
int32 CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus=false)
Definition: Player.cpp:5673
uint32 GetRuneCooldown(uint8 index) const
Definition: Player.h:2466
float m_realDodge
Definition: Player.h:2605
void SendLoot(ObjectGuid guid, LootType loot_type)
Definition: Player.cpp:7527
void learnSkillRewardedSpells(uint32 id, uint32 value)
Definition: Player.cpp:11279
void _ApplyItemMods(Item *item, uint8 slot, bool apply)
Definition: Player.cpp:6345
uint32 GetArenaTeamId(uint8 slot) const
Definition: Player.cpp:15323
float GetRatingMultiplier(CombatRating cr) const
Definition: Player.cpp:5017
WorldLocation GetCorpseLocation() const
Definition: Player.h:1982
void RemoveCategoryCooldown(uint32 cat)
Definition: Player.cpp:3422
WorldLocation teleportStore_dest
Definition: Player.h:2904
PartyResult CanUninviteFromGroup(ObjectGuid targetPlayerGUID=ObjectGuid::Empty) const
Definition: Player.cpp:12200
void _SaveGlyphs(CharacterDatabaseTransaction trans)
Definition: Player.cpp:14115
void SetHonorPoints(uint32 value)
Definition: Player.cpp:6039
bool m_isInstantFlightOn
Definition: Player.h:2934
void ApplyManaRegenBonus(int32 amount, bool apply)
Definition: StatSystem.cpp:876
time_t mSemaphoreTeleport_Near
Definition: Player.h:2906
DeclinedName * m_declinedname
Definition: Player.h:2856
void InitTaxiNodesForLevel()
Definition: Player.h:1103
ActionButton const * GetActionButton(uint8 button)
Definition: Player.cpp:5488
void _LoadSkills(PreparedQueryResult result)
Definition: Player.cpp:12842
bool CanJoinToBattleground() const
Definition: Player.cpp:10615
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Player.cpp:10349
void SetDailyQuestStatus(uint32 quest_id)
Definition: Player.cpp:11383
Corpse * GetCorpse() const
Definition: Player.cpp:4545
int16 m_baseRatingValue[MAX_COMBAT_RATING]
Definition: Player.h:2768
bool IsAtLootRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:11978
void RemoveItem(uint8 bag, uint8 slot, bool update, bool swap=false)
bool m_IsBGRandomWinner
Definition: Player.h:2622
void RestoreAllSpellMods(uint32 ownerAuraId=0, Aura *aura=nullptr)
Definition: Player.cpp:9302
void DurabilityLoss(Item *item, double percent)
Definition: Player.cpp:4576
void BeginCinematic()
Definition: Player.cpp:15060
~Player() override
Definition: Player.cpp:421
uint32 m_drunkTimer
Definition: Player.h:2804
bool Has310Flyer(bool checkAllSpells, uint32 excludeSpellId=0)
Definition: Player.cpp:3376
WorldLocation & GetTeleportDest()
Definition: Player.h:2031
RewardedQuestSet m_RewardedQuests
Definition: Player.h:2744
void InitStatsForLevel(bool reapplyMods=false)
Definition: Player.cpp:2492
void SendInitWorldStates(uint32 zone, uint32 area)
Definition: Player.cpp:7929
void HandleSobering()
The player sobers by 1% every 9 seconds.
Definition: Player.cpp:976
float GetAmmoDPS() const
Definition: Player.h:1266
uint32 m_contestedPvPTimer
Definition: Player.h:2614
void ClearChannelWatch()
Definition: Player.cpp:4847
void ProcessDelayedOperations()
Definition: Player.cpp:1580
float GetAverageItemLevel()
Definition: Player.cpp:14838
void SetMountBlockId(uint32 mount)
Definition: Player.h:2561
float m_homebindY
Definition: Player.h:2337
float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
Definition: Player.cpp:5038
bool SetWaterWalking(bool apply, bool packetOnly=false) override
Definition: Player.cpp:15022
void SendSavedInstances()
uint32 m_lastCinematicCheck
Definition: Player.h:2940
int32 CalculateCorpseReclaimDelay(bool load=false)
Definition: Player.cpp:12126
Creature * GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
Definition: Player.cpp:2023
bool IsFFAPvP()
Definition: Player.cpp:15332
void SendLootError(ObjectGuid guid, LootError error)
Definition: Player.cpp:7907
void ResetWeeklyQuestStatus()
Definition: Player.cpp:11459
void SetSemaphoreTeleportNear(time_t tm)
Definition: Player.h:2035
void SendRefundInfo(Item *item)
Definition: Player.cpp:14643
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false, bool sendChatMessage=true)
void AutoUnequipOffhandIfNeed(bool force=false)
Definition: Player.cpp:11666
bool isGMChat() const
Definition: Player.h:1116
bool IsGroupVisibleFor(Player const *p) const
Definition: Player.cpp:2232
float OCTRegenHPPerSpirit()
Definition: Player.cpp:5052
uint32 m_stableSlots
Definition: Player.h:1339
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
bool resetTalents(bool noResetCost=false)
Definition: Player.cpp:3595
uint32 m_Played_time[MAX_PLAYED_TIME_INDEX]
Definition: Player.h:1139
RuneType GetCurrentRune(uint8 index) const
Definition: Player.h:2465
uint32 m_baseSpellPower
Definition: Player.h:2769
void UpdateMaxHealth() override
Definition: StatSystem.cpp:289
void SetLastPetSpell(uint32 petspell)
Definition: Player.h:2423
bool IsGameMaster() const
Definition: Player.h:1114
void SendMovieStart(uint32 MovieId)
Definition: Player.cpp:5545
void SetActiveCinematicCamera(uint32 cinematicCameraId=0)
Definition: Player.h:2577
void SetPendingBind(uint32 instanceId, uint32 bindTimer)
Definition: Player.h:2401
uint32 _restFlagMask
Definition: Player.h:2826
void _SaveAuras(CharacterDatabaseTransaction trans, bool logout)
Item * EquipItem(uint16 pos, Item *pItem, bool update)
PlayerSocial * GetSocial()
Definition: Player.h:1100
void SetPvPDeath(bool on)
Definition: Player.h:1124
uint32 GetSpec(int8 spec=-1)
Definition: Player.cpp:15142
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1300
Optional< float > GetFarSightDistance() const
Definition: Player.cpp:15392
void SetEquipmentSet(uint32 index, EquipmentSet eqset)
Definition: Player.cpp:13636
void SetNeedToSaveGlyphs(bool val)
Definition: Player.h:2558
void SendClearCooldown(uint32 spell_id, Unit *target)
Definition: Player.cpp:13789
void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool includeMargin=false, Player const *skipped_rcvr=nullptr) override
Definition: Player.cpp:5507
uint8 m_grantableLevels
Definition: Player.h:2864
void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply)
Definition: Player.cpp:6765
void ModifySkillBonus(uint32 skillid, int32 val, bool talent)
Definition: Player.cpp:5144
TrainerSpellState GetTrainerSpellState(TrainerSpell const *trainer_spell) const
Definition: Player.cpp:3788
Item * m_items[PLAYER_SLOTS_COUNT]
Definition: Player.h:2730
uint32 GetMoney() const
Definition: Player.h:1539
void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete=false)
Definition: Player.cpp:13101
uint16 m_homebindAreaId
Definition: Player.h:2335
Difficulty m_raidMapDifficulty
Definition: Player.h:2726
void DurabilityPointsLossAll(int32 points, bool inventory)
Definition: Player.cpp:4594
uint32 m_zoneUpdateId
Definition: Player.h:2807
float GetSpellCritFromIntellect()
Definition: Player.cpp:5000
bool m_isInWater
Definition: Player.h:2901
bool IsVisibleGloballyFor(Player const *player) const
Definition: Player.cpp:10704
static uint8 GetAttackBySlot(uint8 slot)
void AddItemDurations(Item *item)
Definition: Player.cpp:11657
PlayerTaxi m_taxi
Definition: Player.h:1102
uint8 m_MirrorTimerFlagsLast
Definition: Player.h:2900
std::vector< ItemSetEffect * > ItemSetEff
Definition: Player.h:2178
Corpse * CreateCorpse()
Definition: Player.cpp:4432
uint32 GetCorpseReclaimDelay(bool pvp) const
Definition: Player.cpp:12109
void SetFreeTalentPoints(uint32 points)
Definition: Player.cpp:3690
void SetTitle(CharTitlesEntry const *title, bool lost=false)
Definition: Player.cpp:12525
Creature * m_CinematicObject
Definition: Player.h:2944
time_t m_lastDailyQuestTime
Definition: Player.h:2802
void SetWeeklyQuestStatus(uint32 quest_id)
Definition: Player.cpp:11425
void SendNotifyLootItemRemoved(uint8 lootSlot)
Definition: Player.cpp:7922
uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank)
Definition: Player.cpp:4674
uint8 GetActiveSpec() const
Definition: Player.h:1673
time_t m_resetTalentsTime
Definition: Player.h:2829
uint32 m_baseHealthRegen
Definition: Player.h:2772
uint32 m_charmUpdateTimer
Definition: Player.h:2552
static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type)
Definition: Player.cpp:9406
uint32 m_summon_mapid
Definition: Player.h:2850
void StoreLootItem(uint8 lootSlot, Loot *loot)
Definition: Player.cpp:12704
void UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 new_value)
void ToggleAFK()
Definition: Player.cpp:1261
int8 m_comboPoints
Definition: Player.h:2739
uint32 GetReputation(uint32 factionentry) const
Definition: Player.cpp:14473
void ApplyEquipCooldown(Item *pItem)
Definition: Player.cpp:11058
Difficulty m_raidDifficulty
Definition: Player.h:2725
Group * GetGroupInvite()
Definition: Player.h:2429
void PossessSpellInitialize()
Definition: Player.cpp:8971
bool isDND() const
Definition: Player.h:1094
void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check=false)
float m_lastFallZ
Definition: Player.h:2896
void ModifyHonorPoints(int32 value, CharacterDatabaseTransaction trans=CharacterDatabaseTransaction(nullptr))
Definition: Player.cpp:6057
WhisperListContainer WhisperList
Definition: Player.h:2596
void SetGMVisible(bool on)
Definition: Player.cpp:2207
void InitRunes()
Definition: Player.cpp:12644
void _SaveActions(CharacterDatabaseTransaction trans)
bool m_summon_asSpectator
Definition: Player.h:2854
bool CanResummonPet(uint32 spellid)
Definition: Player.cpp:13405
uint32 m_baseManaRegen
Definition: Player.h:2771
time_t m_logintime
Definition: Player.h:1137
Difficulty GetStoredRaidDifficulty() const
Definition: Player.h:1865
void SetReputation(uint32 factionentry, uint32 value)
Definition: Player.cpp:14469
void ApplySpellPowerBonus(int32 amount, bool apply)
Definition: StatSystem.cpp:160
int32 m_MirrorTimer[MAX_TIMERS]
Definition: Player.h:2898
uint32 _innTriggerId
Definition: Player.h:2824
void SetBindPoint(ObjectGuid guid)
Definition: Player.cpp:8614
void RemoveItemDurations(Item *item)
Definition: Player.cpp:11645
void PrepareCharmAISpells()
Definition: Player.cpp:14536
QuestStatus GetQuestStatus(uint32 quest_id) const
void ConvertRune(uint8 index, RuneType newType)
Definition: Player.cpp:12605
bool HasCasterSpec()
Definition: Player.cpp:15240
static bool BuildEnumData(PreparedQueryResult result, WorldPacket *data)
Definition: Player.cpp:1102
void _SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans)
Definition: Player.cpp:14938
void SendEnchantmentDurations()
void _LoadActions(PreparedQueryResult result)
static std::unordered_map< int, bgZoneRef > bgZoneIdToFillWorldStates
Definition: Player.h:2573
T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=nullptr, bool temporaryPet=false)
Definition: Player.h:2955
bool IsDailyQuestDone(uint32 quest_id)
Definition: Player.cpp:11409
uint32 m_ArenaTeamIdInvited
Definition: Player.h:2751
uint32 m_resurrectMap
Definition: Player.h:2785
uint32 m_recallMap
Definition: Player.h:2324
uint8 GetActiveSpecMask() const
Definition: Player.h:1674
void StopCastingBindSight()
Definition: Player.cpp:12346
uint32 GetBattlegroundId() const
Definition: Player.h:2192
static bool IsValidGender(uint8 Gender)
Definition: Player.h:1506
void SendMessageToSet(WorldPacket *data, bool self) override
Definition: Player.h:1968
void ModifyArenaPoints(int32 value, CharacterDatabaseTransaction trans=CharacterDatabaseTransaction(nullptr))
If trans is specified, honor save query will be added to trans.
Definition: Player.cpp:6073
bool IsAlwaysDetectableFor(WorldObject const *seer) const override
Definition: Player.cpp:10692
float m_recallY
Definition: Player.h:2326
uint32 GetSpellCooldownDelay(uint32 spell_id) const
Definition: Player.h:1731
bool UpdateAllStats() override
Definition: StatSystem.cpp:181
void SendLogXPGain(uint32 GivenXP, Unit *victim, uint32 BonusXP, bool recruitAFriend=false, float group_rate=1.0f)
Definition: Player.cpp:2287
bool IsFalling() const
Definition: Player.cpp:2098
void LeaveBattleground(Battleground *bg=nullptr)
Definition: Player.cpp:10585
void ResetAllPowers()
Definition: Player.cpp:1983
void SetClientControl(Unit *target, bool allowMove, bool packetOnly=false)
Definition: Player.cpp:12050
void UpdateRating(CombatRating cr)
void ApplyEquipSpell(SpellInfo const *spellInfo, Item *item, bool apply, bool form_change=false)
Definition: Player.cpp:6916
ReputationRank GetReputationRank(uint32 faction_id) const
Definition: Player.cpp:5666
void TradeCancel(bool sendback)
void UpdateArea(uint32 newArea)
bool IsDeveloper() const
Definition: Player.h:1110
bool IsSpectator() const
Definition: Player.h:2529
Player * GetSelectedPlayer() const
Definition: Player.cpp:10765
void SetHasDelayedTeleport(bool setting)
Definition: Player.h:2889
void SendBuyError(BuyResult msg, Creature *creature, uint32 item, uint32 param)
void ModifySpellCooldown(uint32 spellId, int32 cooldown)
Definition: Player.cpp:10354
Unit * GetSelectedUnit() const
Definition: Player.cpp:10757
void setDeathState(DeathState s, bool despawn=false) override
Definition: Player.cpp:1030
static Item * _LoadMailedItem(ObjectGuid const &playerGuid, Player *player, uint32 mailId, Mail *mail, Field *fields)
Item * GetWeaponForAttack(WeaponAttackType attackType, bool useable=false) const
uint32 m_questRewardTalentCount
Definition: Player.h:2831
Player * GetNextRandomRaidMember(float radius)
Definition: Player.cpp:12174
void AddToWorld() override
Definition: Player.cpp:1662
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
void RemoveAllSpellCooldown()
Definition: Player.cpp:3465
bool HasAtLoginFlag(AtLoginFlags f) const
Definition: Player.h:2367
void SetHas310Flyer(bool on)
Definition: Player.h:1123
uint8 GetSpecsCount() const
Definition: Player.h:1676
void RewardReputation(Unit *victim, float rate)
Definition: Player.cpp:5753
bool m_NeedToSaveGlyphs
Definition: Player.h:2601
void RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
Definition: Player.cpp:13096
void SetMovement(PlayerMovementType pType)
Definition: Player.cpp:4236
void SetIsSpectator(bool on)
Definition: Player.cpp:14490
bool isHonorOrXPTarget(Unit *victim) const
Definition: Player.cpp:11864
static void LeaveAllArenaTeams(ObjectGuid guid)
Definition: Player.cpp:9474
RefundableItemsSet m_refundableItems
Definition: Player.h:2877
void HandleDrowning(uint32 time_diff)
Definition: Player.cpp:859
uint32 m_HomebindTimer
Definition: Player.h:2398
uint32 GetPhaseMaskForSpawn() const
Definition: Player.cpp:12940
void UpdateTitansGrip()
uint64 m_auraRaidUpdateMask
Definition: Player.h:2842
bool m_canTitanGrip
Definition: Player.h:2818
bool InArena() const
Definition: Player.cpp:11498
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3770
void UpdateSkillsForLevel()
void SetSemaphoreTeleportFar(time_t tm)
Definition: Player.h:2036
uint8 GetMostPointsTalentTree() const
Definition: Player.cpp:14438
ActionButtonList m_actionButtons
Definition: Player.h:2765
void BuildPlayerRepop()
Definition: Player.cpp:4266
void UninviteFromGroup()
Definition: Player.cpp:2254
int32 getMaxTimer(MirrorTimerType timer)
Definition: Player.cpp:832
bool HasSpellMod(SpellModifier *mod, Spell *spell)
Definition: Player.cpp:9135
bool m_canBlock
Definition: Player.h:2817
uint8 GetSubGroup() const
Definition: Player.h:2435
bool isAFK() const
Definition: Player.h:1093
void _RemoveAllStatBonuses()
Definition: StatSystem.cpp:954
void _SaveSpellCooldowns(CharacterDatabaseTransaction trans, bool logout)
Definition: Player.cpp:3514
uint8 m_cinematic
Definition: Player.h:2794
void VehicleSpellInitialize()
Definition: Player.cpp:8999
bool MustDelayTeleport() const
Definition: Player.h:2886
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3414
Player(WorldSession *session)
Definition: Player.cpp:150
int32 m_spellPenetrationItemMod
Definition: Player.h:2773
bool SetFeatherFall(bool apply, bool packetOnly=false) override
Definition: Player.cpp:15039
void SetFreePrimaryProfessions(uint16 profs)
Definition: Player.h:1702
void SendInitialActionButtons() const
Definition: Player.h:1783
void SetMap(Map *map) override
Definition: Player.cpp:13812
bool isAcceptWhispers() const
Definition: Player.h:1112
void Yell(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles yelled message in regular chat based on declared language and in config pre-defined Range.
Definition: Player.cpp:8795
bool CanReportAfkDueToLimit()
Definition: Player.cpp:10624
void CastItemUseSpell(Item *item, SpellCastTargets const &targets, uint8 cast_count, uint32 glyphIndex)
Definition: Player.cpp:7139
void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg=0)
Definition: Player.cpp:11004
void DurabilityPointsLoss(Item *item, int32 points)
Definition: Player.cpp:4620
uint8 m_activeSpec
Definition: Player.h:2760
void Say(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles said message in regular chat based on declared language and in config pre-defined Range.
Definition: Player.cpp:8776
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const
If trans is specified, arena point save query will be added to trans.
Definition: Player.cpp:10153
void TextEmote(std::string_view text, WorldObject const *=nullptr, bool=false) override
Outputs an universal text which is supposed to be an action.
Definition: Player.cpp:8814
uint32 GetChampioningFaction() const
Definition: Player.h:2503
void LeftChannel(Channel *c)
Definition: Player.cpp:4832
WorldSession * m_session
Definition: Player.h:2789
void SetRuneConvertAura(uint8 index, AuraEffect const *aura)
Definition: Player.h:2476
void ReportedAfkBy(Player *reporter)
This player has been blamed to be inactive in a battleground.
Definition: Player.cpp:10634
uint32 GetShieldBlockValue() const override
Definition: Player.cpp:4921
void ApplyFeralAPBonus(int32 amount, bool apply)
Definition: StatSystem.cpp:317
uint32 m_flightSpellActivated
Definition: Player.h:2936
Optional< float > _farSightDistance
Definition: Player.h:2948
bool IsAffectedBySpellmod(SpellInfo const *spellInfo, SpellModifier *mod, Spell *spell=nullptr)
Definition: Player.cpp:9143
void RefundItem(Item *item)
Definition: Player.cpp:14706
float GetRestBonus() const
Definition: Player.h:1148
void Whisper(std::string_view text, Language language, Player *receiver, bool=false) override
Handles whispers from Addons and players based on sender, receiver's guid and language.
Definition: Player.cpp:8833
uint32 teleportStore_options
Definition: Player.h:2905
void AddSpellMod(SpellModifier *mod, bool apply)
Definition: Player.cpp:9187
void SetFactionForRace(uint8 race)
Definition: Player.cpp:5653
void SendEquipError(InventoryResult msg, Item *pItem, Item *pItem2=nullptr, uint32 itemid=0)
void SendActionButtons(uint32 state) const
Definition: Player.cpp:5388
Item * GetItemByGuid(ObjectGuid guid) const
uint32 m_ArmorProficiency
Definition: Player.h:2815
void ToggleDND()
Definition: Player.cpp:1270
void _LoadInstanceTimeRestrictions(PreparedQueryResult result)
Definition: Player.cpp:14885
void ResummonPetTemporaryUnSummonedIfAny()
Definition: Player.cpp:13386
ObjectGuid GetComboTarget() const
Definition: Player.h:1573
void ApplyHealthRegenBonus(int32 amount, bool apply)
Definition: StatSystem.cpp:882
void AddRunePower(uint8 index)
Definition: Player.cpp:12627
void SendItemDurations()
void StoreRaidMapDifficulty()
Definition: Player.h:1868
uint32 CalculateTalentsPoints() const
Definition: Player.cpp:12802
void learnQuestRewardedSpells()
Definition: Player.cpp:11266
void RemovedInsignia(Player *looterPlr)
Definition: Player.cpp:7488
bool isDebugAreaTriggers
Definition: Player.h:2509
void RemoveFromWorld() override
Definition: Player.cpp:1674
void JoinedChannel(Channel *c)
Definition: Player.cpp:4827
bool CanSeeSpellClickOn(Creature const *creature) const
Definition: Player.cpp:13423
WorldLocation GetStartPosition() const
Definition: Player.cpp:10659
uint32 GetFreePrimaryProfessionPoints() const
Definition: Player.h:1701
Difficulty GetDungeonDifficulty() const
Definition: Player.h:1863
SpellCooldowns m_spellCooldowns
Definition: Player.h:2920
void CleanupAfterTaxiFlight()
Definition: Player.cpp:9731
SeasonalEventQuestMap m_seasonalquests
Definition: Player.h:2641
void SetGlyph(uint8 slot, uint32 glyph, bool save)
Definition: Player.h:1691
void SendEquipmentSetList()
Definition: Player.cpp:13606
void SendQuestGiverStatusMultiple()
Definition: Player.cpp:7442
bool IsOutdoorPvPActive()
Definition: Player.cpp:6225
PlayerMails m_mail
Definition: Player.h:2753
void _AddSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 itemid, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false)
Definition: Player.cpp:10327
uint32 m_cinematicDiff
Definition: Player.h:2939
bool CanInteractWithQuestGiver(Object *questGiver)
Definition: Player.cpp:2005
void _addTalentAurasAndSpells(uint32 spellId)
Definition: Player.cpp:2913
void SetMover(Unit *target)
Definition: Player.cpp:12091
void RegenerateAll()
Definition: Player.cpp:1716
void StopMirrorTimer(MirrorTimerType Type)
Definition: Player.cpp:765
bool IsImmuneToEnvironmentalDamage()
Definition: Player.cpp:773
uint32 m_groupUpdateMask
Definition: Player.h:2841
void UpdateHonorFields()
BGData m_bgData
Definition: Player.h:2621
uint32 GetGracePeriod(uint8 index) const
Definition: Player.h:2467
float OCTRegenMPPerSpirit()
Definition: Player.cpp:5075
Spell * m_spellModTakingSpell
Definition: Player.h:2505
void CorrectMetaGemEnchants(uint8 slot, bool apply)
Definition: Player.cpp:10470
uint32 resetTalentsCost() const
Definition: Player.cpp:3562
Mail * GetMail(uint32 id)
Definition: Player.cpp:3696
void CheckAllAchievementCriteria()
Definition: Player.cpp:13071
void AddKnownCurrency(uint32 itemId)
Definition: Player.cpp:13365
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=nullptr) const
Definition: Player.h:1218
void _LoadSpellCooldowns(PreparedQueryResult result)
Definition: Player.cpp:3478
bool IsPvP()
Definition: Player.cpp:15341
RuneType GetBaseRune(uint8 index) const
Definition: Player.h:2464
void _SaveEntryPoint(CharacterDatabaseTransaction trans)
Definition: Player.cpp:13728
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition: Player.cpp:10369
uint32 m_lastpetnumber
Definition: Player.h:2846
void UpdateAttackPowerAndDamage(bool ranged=false) override
Definition: StatSystem.cpp:323
void SendComboPoints()
Definition: Player.cpp:10781
bool CanJoinConstantChannelInZone(ChatChannelsEntry const *channel, AreaTableEntry const *zone)
Definition: Player.cpp:4809
DuelInfo * duel
Definition: Player.h:1817
bool IsInSameGroupWith(Player const *p) const
Definition: Player.cpp:2245
void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty=-1)
Definition: PlayerMisc.cpp:175
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition: Player.cpp:12274
bool NeedToSaveGlyphs()
Definition: Player.h:2557
time_t m_Last_tick
Definition: Player.h:1138
static DrunkenState GetDrunkenstateByValue(uint8 value)
Definition: Player.cpp:985
float m_resurrectX
Definition: Player.h:2786
bool IsBeingTeleported() const
Definition: Player.h:2032
uint8 GetOriginalSubGroup() const
Definition: Player.h:2448
void SetMoney(uint32 value)
Definition: Player.h:1549
bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type)
Definition: Player.cpp:5416
void resetSpells()
Definition: Player.cpp:11106
void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply)
Definition: Player.cpp:4853
PlayerTalentMap m_talents
Definition: Player.h:2755
bool CanCaptureTowerPoint() const
Definition: Player.cpp:12431
PlayerMenu * PlayerTalkClass
Definition: Player.h:2177
void SendNotifyLootMoneyRemoved()
Definition: Player.cpp:7916
std::set< Unit * > m_isInSharedVisionOf
Definition: Player.h:2300
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
Definition: Player.cpp:11529
void SetRandomWinner(bool isWinner)
Definition: Player.cpp:14821
void BuildPlayerTalentsInfoData(WorldPacket *data)
Definition: Player.cpp:13446
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition: Player.cpp:11929
uint32 m_GuildIdInvited
Definition: Player.h:2750
float m_homebindX
Definition: Player.h:2336
TeamId GetBgTeamId() const
Definition: Player.h:2255
uint16 m_hostileReferenceCheckTimer
Definition: Player.h:2721
bool m_itemUpdateQueueBlocked
Definition: Player.h:2734
float m_resurrectY
Definition: Player.h:2786
EntryPointData m_entryPointData
Definition: Player.h:2628
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns=false)
Definition: Player.cpp:3430
void ResetAchievements()
Definition: Player.cpp:13076
void LearnDefaultSkills()
Definition: Player.cpp:11150
uint32 m_MountBlockId
Definition: Player.h:2603
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4315
uint32 m_activeCinematicCameraId
Definition: Player.h:2941
void SendSocialList(Player *player, uint32 flags)
Definition: SocialMgr.cpp:124
std::string SaveTaxiDestinationsToString()
Definition: PlayerTaxi.cpp:155
void AddTaxiDestination(uint32 dest)
Definition: PlayerTaxi.h:52
uint32 GetTaxiSource() const
Definition: PlayerTaxi.h:53
bool empty() const
Definition: PlayerTaxi.h:67
uint32 GetTaxiSegment() const
Definition: PlayerTaxi.h:64
void ClearTaxiDestinations()
Definition: PlayerTaxi.h:51
void SetTaxiSegment(uint32 segment)
Definition: PlayerTaxi.h:63
uint32 GetCurrentTaxiPath() const
Definition: PlayerTaxi.cpp:169
std::vector< uint32 > const & GetPath() const
Definition: PlayerTaxi.h:66
void setInt32(const uint8 index, const int32 value)
void setFloat(const uint8 index, const float value)
void setUInt8(const uint8 index, const uint8 value)
void setUInt32(const uint8 index, const uint32 value)
void setUInt16(const uint8 index, const uint16 value)
void setString(const uint8 index, const std::string &value)
void setUInt64(const uint8 index, const uint64 value)
uint16 GetEventIdForQuest() const
Definition: QuestDef.h:327
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:299
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:300
int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:307
bool IsRepeatable() const
Definition: QuestDef.h:278
bool IsDaily() const
Definition: QuestDef.h:282
bool IsAllowedInRaid(Difficulty difficulty) const
Definition: QuestDef.cpp:272
bool IsWeekly() const
Definition: QuestDef.h:283
uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:305
int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:306
int32 GetRewSpellCast() const
Definition: QuestDef.h:268
bool IsMonthly() const
Definition: QuestDef.h:284
void unlink()
Definition: Reference.h:62
void link(TO *toObj, FROM *fromObj)
Definition: Reference.h:45
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing, bool spillOverOnly=false)
int32 GetReputation(uint32 faction_id) const
bool SetReputation(FactionEntry const *factionEntry, int32 standing)
ReputationRank GetRank(FactionEntry const *factionEntry) const
void SendInitialReputations()
void SendForceReactions()
void Initialize(Unit *defVal)
Definition: Unit.h:1406
static uint32 IncreaseSavingMaxValue(uint32 inc)
Definition: SavingSystem.h:35
Definition: Spell.h:284
SpellCastResult prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=nullptr)
Definition: Spell.cpp:3243
void SetSpellValue(SpellValueMod mod, int32 value)
Definition: Spell.cpp:7921
SpellInfo const * m_spellInfo
Definition: Spell.h:520
uint8 m_cast_count
Definition: Spell.h:524
uint32 m_glyphIndex
Definition: Spell.h:525
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:5237
void InitExplicitTargets(SpellCastTargets const &targets)
Definition: Spell.cpp:715
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4310
Item * m_CastItem
Definition: Spell.h:521
UsedSpellMods m_appliedMods
Definition: Spell.h:530
std::array< int32, MAX_SPELL_REAGENTS > Reagent
Definition: SpellInfo.h:368
uint32 PreventionType
Definition: SpellInfo.h:384
uint32 Stances
Definition: SpellInfo.h:328
uint32 GetCategory() const
Definition: SpellInfo.cpp:863
SpellCastResult CheckShapeshift(uint32 form) const
Definition: SpellInfo.cpp:1414
flag96 SpellFamilyFlags
Definition: SpellInfo.h:382
uint32 RecoveryTime
Definition: SpellInfo.h:343
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1195
bool IsPassive() const
Definition: SpellInfo.cpp:1081
uint32 Id
Definition: SpellInfo.h:315
uint8 GetRank() const
Definition: SpellInfo.cpp:2435
bool HasAnyAura() const
Definition: SpellInfo.cpp:884
bool IsRanked() const
Definition: SpellInfo.cpp:2430
bool IsHighRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2522
int32 EquippedItemClass
Definition: SpellInfo.h:370
bool IsAffectedBySpellMod(SpellModifier const *mod) const
Definition: SpellInfo.cpp:1276
bool IsStackableWithRanks() const
Definition: SpellInfo.cpp:1128
uint32 CategoryRecoveryTime
Definition: SpellInfo.h:344
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:1931
std::array< uint32, MAX_SPELL_REAGENTS > ReagentCount
Definition: SpellInfo.h:369
bool NeedsComboPoints() const
Definition: SpellInfo.cpp:1249
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:408
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:387
int32 GetDuration() const
Definition: SpellInfo.cpp:2280
uint32 SpellIconID
Definition: SpellInfo.h:375
SpellInfo const * GetNextRankSpell() const
Definition: SpellInfo.cpp:2454
bool IsPrimaryProfessionFirstRank() const
Definition: SpellInfo.cpp:966
uint32 CalcCastTime(Unit *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:2294
bool HasEffect(SpellEffects effect) const
Definition: SpellInfo.cpp:868
bool IsPositive() const
Definition: SpellInfo.cpp:1220
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1266
uint32 ProcChance
Definition: SpellInfo.h:351
uint32 SpellFamilyName
Definition: SpellInfo.h:381
static bool CheckSpellValid(SpellInfo const *spellInfo, uint32 spellId, bool isTalent)
Definition: SpellMgr.cpp:460
bool operator()(const SpellModifier *a, const SpellModifier *b) const
Definition: Player.cpp:9164
uint32 GetTimer()
Definition: Util.h:46
virtual void RemovePassenger(WorldObject *passenger, bool withAll=false)=0
Definition: Unit.h:1419
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:13270
void ClearUnitState(uint32 f)
Definition: Unit.h:1520
bool IsVehicle() const
Definition: Unit.h:1537
void SetMinion(Minion *minion, bool apply)
Definition: Unit.cpp:10074
bool IsUnderLastManaUseEffect() const
Definition: Unit.cpp:16452
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4222
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true, bool bySelf=false)
Definition: Unit.cpp:3589
uint32 GetCreatePowers(Powers power) const
Definition: Unit.cpp:14778
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:5668
Spell * m_currentSpells[CURRENT_MAX_SPELL]
Definition: Unit.h:2564
uint8 getGender() const
Definition: Unit.h:1547
void SetCreateStat(Stats stat, float val)
Definition: Unit.h:2116
virtual void setDeathState(DeathState s, bool despawn=false)
Definition: Unit.cpp:13712
void SetStat(Stats stat, int32 val)
Definition: Unit.h:1550
Unit * GetCharm() const
Definition: Unit.cpp:10060
void SetResistanceBuffMods(SpellSchools school, bool positive, float val)
Definition: Unit.h:2105
uint32 GetUnitMovementFlags() const
Definition: Unit.h:2355
LiquidTypeEntry const * _lastLiquid
Definition: Unit.h:2603
void RemovePetAura(PetAura const *petSpell)
Definition: Unit.cpp:16507
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5076
void SetFacingTo(float ori)
Definition: Unit.cpp:19637
static uint32 DealDamage(Unit *attacker, Unit *victim, uint32 damage, CleanDamage const *cleanDamage=nullptr, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=nullptr, bool durabilityLoss=true, bool allowGM=false)
Definition: Unit.cpp:773
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:9835
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:9503
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4293
void SetFullHealth()
Definition: Unit.h:1574
void AddToWorld() override
Definition: Unit.cpp:14806
void SetFaction(uint32 faction)
Definition: Unit.cpp:9495
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:9473
virtual void SetCanDualWield(bool value)
Definition: Unit.h:1472
VisibleAuraMap const * GetVisibleAuras()
Definition: Unit.h:2238
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:17189
void AddComboPointHolder(ObjectGuid lowguid)
Definition: Unit.h:2368
bool CanUseAttackType(uint8 attacktype) const
Definition: Unit.h:1705
float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]
Definition: Unit.h:2578
void SetCreateHealth(uint32 val)
Definition: Unit.h:2117
std::list< Aura * > AuraList
Definition: Unit.h:1436
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition: Unit.cpp:3656
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:4681
uint8 m_realRace
Definition: Unit.h:2541
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:3671
Vehicle * m_vehicle
Definition: Unit.h:2599
Creature * GetVehicleCreatureBase() const
Definition: Unit.cpp:17864
int32 CalculateSpellDamage(Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr) const
Definition: Unit.cpp:14008
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1428
void ApplyStatBuffMod(Stats stat, float val, bool apply)
Definition: Unit.h:2113
uint8 m_race
Definition: Unit.h:2542
bool IsPolymorphed() const
Definition: Unit.cpp:16058
Vehicle * GetVehicle() const
Definition: Unit.h:2423
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:2153
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value)
Definition: Unit.h:2205
virtual bool isBeingLoaded() const
Definition: Unit.h:2464
bool IsInDisallowedMountForm() const
Definition: Unit.h:2165
bool IsPvP() const
Definition: Unit.h:1624
bool IsPet() const
Definition: Unit.h:1534
void Dismount()
Definition: Unit.cpp:12739
void SetCharm(Unit *target, bool apply)
Definition: Unit.cpp:10263
void SendTeleportPacket(Position &pos)
Definition: Unit.cpp:19064
bool CanDualWield() const
Definition: Unit.h:1471
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:3626
void SetUnitMovementFlags(uint32 f)
Definition: Unit.h:2356
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:14889
uint32 GetMaxHealth() const
Definition: Unit.h:1560
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:17980
void SendMovementHover(Player *sendTo)
Definition: Unit.cpp:19801
uint8 getClass() const
Definition: Unit.h:1545
float m_createStats[MAX_STATS]
Definition: Unit.h:2548
bool IsAlive() const
Definition: Unit.h:1888
uint8 getRace(bool original=false) const
Definition: Unit.cpp:20028
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:2004
void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply)
Definition: Unit.cpp:16263
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:15987
std::pair< AuraApplicationMap::const_iterator, AuraApplicationMap::const_iterator > AuraApplicationMapBounds
Definition: Unit.h:1429
GameObject * GetGameObject(uint32 spellId) const
Definition: Unit.cpp:5640
void SendPlaySpellVisual(uint32 id)
Definition: Unit.cpp:18028
void SetHealth(uint32 val)
Definition: Unit.cpp:14619
bool IsStandState() const
Definition: Unit.cpp:16037
void SetMaxPower(Powers power, uint32 val)
Definition: Unit.cpp:14749
bool HasStealthAura() const
Definition: Unit.h:1787
uint32 GetFaction() const
Definition: Unit.h:1602
void DisableSpline()
Definition: Unit.cpp:613
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5187
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:2143
std::map< uint8, AuraApplication * > VisibleAuraMap
Definition: Unit.h:1441
void RemoveAurasWithAttribute(uint32 flags)
Definition: Unit.cpp:4633
int32 m_regenTimer
Definition: Unit.h:2593
uint32 m_extraAttacks
Definition: Unit.h:1480
void SendMovementWaterWalking(Player *sendTo)
Definition: Unit.cpp:19742
AuraEffect * GetAuraEffectDummy(uint32 spellid) const
Definition: Unit.cpp:5045
void AddUnitState(uint32 f)
Definition: Unit.h:1518
void ClearComboPointHolders()
Definition: Unit.cpp:16128
void SetCreateMana(uint32 val)
Definition: Unit.h:2119
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:2465
int32 GetMaxPositiveAuraModifier(AuraType auratype)
Definition: Unit.cpp:5411
bool m_ControlledByPlayer
Definition: Unit.h:2431
void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid)
Definition: Unit.cpp:4596
virtual void UpdateDamagePhysical(WeaponAttackType attType)
Definition: StatSystem.cpp:59
HostileRefMgr & getHostileRefMgr()
Definition: Unit.h:2236
virtual bool SetHover(bool enable, bool packetOnly=false)
Definition: Unit.cpp:19773
bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply)
Definition: Unit.cpp:14345
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition: Unit.cpp:14602
uint32 GetPhaseByAuras() const
Definition: Unit.cpp:18152
AuraList & GetSingleCastAuras()
Definition: Unit.h:2048
virtual bool SetCanFly(bool enable, bool packetOnly=false)
Definition: Unit.cpp:19711
bool IsInFlight() const
Definition: Unit.h:1768
void SetResistance(SpellSchools school, int32 val)
Definition: Unit.h:1556
uint32 GetNativeDisplayId() const
Definition: Unit.h:2255
void ClearAllReactives()
Definition: Unit.cpp:16142
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:2352
SafeUnitPointer m_movedByPlayer
Definition: Unit.h:1968
void RemoveStandFlags(uint8 flags)
Definition: Unit.h:1646
uint16 GetMaxSkillValueForLevel(Unit const *target=nullptr) const
Definition: Unit.h:1653
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2354
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1581
bool IsSummon() const
Definition: Unit.h:1531
uint32 GetHealth() const
Definition: Unit.h:1559
uint32 GetCreateHealth() const
Definition: Unit.h:2118
uint32 getRaceMask() const
Definition: Unit.h:1544
void UnsummonAllTotems(bool onDeath=false)
Definition: Unit.cpp:10582
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition: Unit.cpp:9941
virtual bool SetFeatherFall(bool enable, bool packetOnly=false)
Definition: Unit.cpp:19751
void SetPower(Powers power, uint32 val)
Definition: Unit.cpp:14707
bool IsVisible() const
Definition: Unit.h:2214
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:5194
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:2257
void BuildCooldownPacket(WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown)
Definition: Unit.cpp:20007
void RemoveAllDynObjects()
Definition: Unit.cpp:5634
void RemoveArenaAuras()
Definition: Unit.cpp:4834
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1087
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:18163
uint32 GetAttackTime(WeaponAttackType att) const
Definition: Unit.h:1588
TempSummon * ToTempSummon()
Definition: Unit.h:2469
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1902
bool IsFFAPvP() const
Definition: Unit.h:1625
bool CanModifyStats() const
Definition: Unit.h:2192
void BuildMovementPacket(ByteBuffer *data) const
Definition: Unit.cpp:18964
bool IsMounted() const
Definition: Unit.h:1648
virtual void SetDisplayId(uint32 modelId)
Definition: Unit.cpp:16071
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4420
MotionMaster * GetMotionMaster()
Definition: Unit.h:2345
void RemovePlayerFromVision(Player *player)
Definition: Unit.cpp:10558
float GetCreateStat(Stats stat) const
Definition: Unit.h:2124
CharmInfo * GetCharmInfo()
Definition: Unit.h:1963
Unit * GetFirstControlled() const
Definition: Unit.cpp:10452
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:17873
void SetArmor(int32 val)
Definition: Unit.h:1552
void ApplyCastTimePercentMod(float val, bool apply)
Definition: Unit.cpp:16279
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1519
AuraMap m_ownedAuras
Definition: Unit.h:2566
uint32 getClassMask() const
Definition: Unit.h:1546
bool IsInFeralForm() const
Definition: Unit.h:2159
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:9649
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:5490
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1894
bool HasInvisibilityAura() const
Definition: Unit.h:1788
void RemoveFromWorld() override
Definition: Unit.cpp:14814
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1528
bool isTargetableForAttack(bool checkFakeDeath=true, Unit const *byWho=nullptr) const
Definition: Unit.cpp:13036
float GetStat(Stats stat) const
Definition: Unit.h:1549
bool m_applyResilience
Definition: Unit.h:2606
void RestoreDisplayId()
Definition: Unit.cpp:16079
bool m_canDualWield
Definition: Unit.h:1481
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1900
virtual bool SetDisableGravity(bool disable, bool packetOnly=false)
Definition: Unit.cpp:19674
Powers getPowerType() const
Definition: Unit.h:1578
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:14669
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:4610
uint32 GetPower(Powers power) const
Definition: Unit.h:1580
void SendMovementFeatherFall(Player *sendTo)
Definition: Unit.cpp:19764
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:5386
bool IsFlying() const
Definition: Unit.h:2454
uint8 getLevel() const
Definition: Unit.h:1539
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1435
void InitStatBuffMods()
Definition: Unit.h:2108
void SetAttackTime(WeaponAttackType att, uint32 val)
Definition: Unit.h:1594
uint32 GetCreateMana() const
Definition: Unit.h:2120
bool IsTotem() const
Definition: Unit.h:1536
void setPowerType(Powers power)
Definition: Unit.cpp:9418
bool IsAlwaysDetectableFor(WorldObject const *seer) const override
Definition: Unit.cpp:13388
bool IsImmunedToDamageOrSchool(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:12143
virtual void Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const *target)
Definition: Unit.cpp:20141
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:9644
void RemoveAllMinionsByEntry(uint32 entry)
Definition: Unit.cpp:10250
bool AttackStop()
Definition: Unit.cpp:9802
static void CalcAbsorbResist(DamageInfo &dmgInfo, bool Splited=false)
Definition: Unit.cpp:1875
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:2047
static void DealDamageMods(Unit const *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:763
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const
Definition: Unit.cpp:5218
void RemoveCharmAuras()
Definition: Unit.cpp:10574
bool IsInCombat() const
Definition: Unit.h:1770
float GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo *spellProto) const
Definition: Unit.cpp:12666
virtual bool SetWaterWalking(bool enable, bool packetOnly=false)
Definition: Unit.cpp:19729
void RemoveAllControlled(bool onDeath=false)
Definition: Unit.cpp:10463
float GetWeaponProcChance() const
Definition: Unit.cpp:12655
ObjectGuid GetPetGUID() const
Definition: Unit.h:1904
bool isDead() const
Definition: Unit.h:1890
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:18807
void CombatStopWithPets(bool includingCast=false)
Definition: Unit.cpp:9851
static uint32 GetGameTimeMS()
What time is it? in ms.
Definition: World.h:246
uint32 GetMapId() const
Definition: Object.h:486
WorldLocation(uint32 _mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
Definition: Object.h:463
void WorldRelocate(const WorldLocation &loc)
Definition: Object.h:469
uint32 m_mapId
Definition: Object.h:529
uint32 GetPhaseMask() const
Definition: Object.h:717
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition: Object.cpp:1343
virtual void ResetMap()
Definition: Object.cpp:2228
std::string const & GetName() const
Definition: Object.h:729
std::string m_name
Definition: Object.h:901
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1240
virtual bool IsNeverVisible() const
Definition: Object.h:924
bool HasAllowedLooter(ObjectGuid guid) const
Definition: Object.cpp:3247
float GetTransOffsetX() const
Definition: Object.h:868
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition: Object.h:790
Map * FindMap() const
Definition: Object.h:801
uint32 GetInstanceId() const
Definition: Object.h:714
bool IsOutdoors() const
Definition: Object.cpp:3216
void setActive(bool isActiveObject)
Definition: Object.cpp:1136
Map * GetMap() const
Definition: Object.h:800
float GetDistance(const WorldObject *obj) const
Definition: Object.cpp:1293
float GetTransOffsetY() const
Definition: Object.h:869
virtual void SetMap(Map *map)
Definition: Object.cpp:2203
float GetTransOffsetZ() const
Definition: Object.h:870
void AddObjectToRemoveList()
Definition: Object.cpp:2246
Transport * GetTransport() const
Definition: Object.h:867
void UpdatePositionData()
Definition: Object.cpp:1202
bool m_isActive
Definition: Object.h:902
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr) const
Definition: Object.cpp:2436
virtual float GetSightRange(const WorldObject *target=nullptr) const
Definition: Object.cpp:1831
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1369
float GetVisibilityRange() const
Definition: Object.cpp:1814
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:793
uint32 GetAreaId() const
Definition: Object.cpp:3199
float GetTransOffsetO() const
Definition: Object.h:871
uint32 GetZoneId() const
Definition: Object.cpp:3191
MovementInfo m_movementInfo
Definition: Object.h:877
bool IsInMap(const WorldObject *obj) const
Definition: Object.cpp:1333
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:792
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:3207
float GetObjectSize() const
Definition: Object.cpp:2843
float GetDistance2d(const WorldObject *obj) const
Definition: Object.cpp:1311
Transport * m_transport
Definition: Object.h:916
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:69
Player session in the World.
Definition: WorldSession.h:242
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
AccountTypes GetSecurity() const
Definition: WorldSession.h:269
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:408
bool PlayerLogout() const
Definition: WorldSession.h:248
uint32 GetCurrentVendor() const
Definition: WorldSession.h:276
uint32 GetRecruiterId() const
Definition: WorldSession.h:435
QueryCallbackProcessor & GetQueryProcessor()
Definition: WorldSession.h:991
void SendActivateTaxiReply(ActivateTaxiReply reply)
void ResetTimeSync()
void SendPetitionQueryOpcode(ObjectGuid petitionguid)
uint32 GetAccountId() const
Definition: WorldSession.h:271
void DoLootRelease(ObjectGuid lguid)
uint32 GetLatency() const
Definition: WorldSession.h:411
char const * GetAcoreString(uint32 entry) const
void SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathNode=0)
Definition: Util.h:483
@ SMSG_LOOT_CLEAR_MONEY
Definition: Opcodes.h:387
@ SMSG_PET_UPDATE_COMBO_POINTS
Definition: Opcodes.h:1200
@ SMSG_MOVE_LAND_WALK
Definition: Opcodes.h:253
@ SMSG_TALENTS_INFO
Definition: Opcodes.h:1246
@ SMSG_NEW_WORLD
Definition: Opcodes.h:92
@ MSG_MOVE_HOVER
Definition: Opcodes.h:277
@ SMSG_LOOT_REMOVED
Definition: Opcodes.h:384
@ SMSG_MOVE_FEATHER_FALL
Definition: Opcodes.h:272
@ SMSG_MOVE_SET_HOVER
Definition: Opcodes.h:274
@ SMSG_RAID_INSTANCE_MESSAGE
Definition: Opcodes.h:792
@ SMSG_INSTANCE_DIFFICULTY
Definition: Opcodes.h:857
@ SMSG_COOLDOWN_EVENT
Definition: Opcodes.h:339
@ SMSG_BUY_ITEM
Definition: Opcodes.h:450
@ SMSG_MOVE_WATER_WALK
Definition: Opcodes.h:252
@ SMSG_FORCE_MOVE_UNROOT
Definition: Opcodes.h:264
@ SMSG_SET_PROFICIENCY
Definition: Opcodes.h:325
@ MSG_MOVE_UPDATE_CAN_FLY
Definition: Opcodes.h:971
@ SMSG_TRIGGER_CINEMATIC
Definition: Opcodes.h:280
@ SMSG_ITEM_REFUND_INFO_RESPONSE
Definition: Opcodes.h:1232
@ SMSG_DUEL_INBOUNDS
Definition: Opcodes.h:391
@ SMSG_LOOT_RESPONSE
Definition: Opcodes.h:382
@ SMSG_DUEL_WINNER
Definition: Opcodes.h:393
@ SMSG_CROSSED_INEBRIATION_THRESHOLD
Definition: Opcodes.h:991
@ SMSG_TRIGGER_MOVIE
Definition: Opcodes.h:1154
@ SMSG_RECEIVED_MAIL
Definition: Opcodes.h:675
@ SMSG_LOG_XPGAIN
Definition: Opcodes.h:494
@ SMSG_PVP_CREDIT
Definition: Opcodes.h:682
@ MSG_TALENT_WIPE_CONFIRM
Definition: Opcodes.h:712
@ MSG_MOVE_WATER_WALK
Definition: Opcodes.h:719
@ SMSG_MOVE_GRAVITY_DISABLE
Definition: Opcodes.h:1260
@ SMSG_CONVERT_RUNE
Definition: Opcodes.h:1188
@ SMSG_MODIFY_COOLDOWN
Definition: Opcodes.h:1199
@ SMSG_PRE_RESURRECT
Definition: Opcodes.h:1202
@ SMSG_QUESTGIVER_STATUS_MULTIPLE
Definition: Opcodes.h:1078
@ SMSG_ACTION_BUTTONS
Definition: Opcodes.h:327
@ SMSG_DUEL_OUTOFBOUNDS
Definition: Opcodes.h:390
@ SMSG_ITEM_COOLDOWN
Definition: Opcodes.h:206
@ SMSG_FORCE_MOVE_ROOT
Definition: Opcodes.h:262
@ SMSG_TRANSFER_PENDING
Definition: Opcodes.h:93
@ SMSG_MOVE_GRAVITY_ENABLE
Definition: Opcodes.h:1262
@ SMSG_REMOVED_SPELL
Definition: Opcodes.h:545
@ SMSG_INITIAL_SPELLS
Definition: Opcodes.h:328
@ SMSG_MOVE_NORMAL_FALL
Definition: Opcodes.h:273
@ SMSG_CORPSE_RECLAIM_DELAY
Definition: Opcodes.h:647
@ SMSG_ADD_RUNE_POWER
Definition: Opcodes.h:1190
@ SMSG_CLEAR_COOLDOWN
Definition: Opcodes.h:508
@ SMSG_UPDATE_COMBO_POINTS
Definition: Opcodes.h:955
@ SMSG_EQUIPMENT_SET_SAVED
Definition: Opcodes.h:341
@ SMSG_START_MIRROR_TIMER
Definition: Opcodes.h:503
@ SMSG_SET_FLAT_SPELL_MODIFIER
Definition: Opcodes.h:644
@ SMSG_LEVELUP_INFO
Definition: Opcodes.h:498
@ SMSG_RESYNC_RUNES
Definition: Opcodes.h:1189
@ SMSG_SET_PCT_SPELL_MODIFIER
Definition: Opcodes.h:645
@ SMSG_TITLE_EARNED
Definition: Opcodes.h:913
@ SMSG_DUEL_COUNTDOWN
Definition: Opcodes.h:725
@ MSG_MOVE_FEATHER_FALL
Definition: Opcodes.h:718
@ SMSG_PET_SPELLS
Definition: Opcodes.h:407
@ SMSG_BINDPOINTUPDATE
Definition: Opcodes.h:371
@ MSG_MOVE_TELEPORT_ACK
Definition: Opcodes.h:229
@ SMSG_MOVE_UNSET_HOVER
Definition: Opcodes.h:275
@ SMSG_INIT_WORLD_STATES
Definition: Opcodes.h:736
@ SMSG_DURABILITY_DAMAGE_DEATH
Definition: Opcodes.h:731
@ SMSG_BINDER_CONFIRM
Definition: Opcodes.h:777
@ SMSG_MOVE_SET_CAN_FLY
Definition: Opcodes.h:865
@ SMSG_LOOT_RELEASE_RESPONSE
Definition: Opcodes.h:383
@ SMSG_SUPERCEDED_SPELL
Definition: Opcodes.h:330
@ SMSG_LOGIN_SETTIMESPEED
Definition: Opcodes.h:96
@ SMSG_MOVE_UNSET_CAN_FLY
Definition: Opcodes.h:866
@ SMSG_SEND_UNLEARN_SPELLS
Definition: Opcodes.h:1084
@ SMSG_DEATH_RELEASE_LOC
Definition: Opcodes.h:918
@ SMSG_DUEL_COMPLETE
Definition: Opcodes.h:392
@ SMSG_SEND_MAIL_RESULT
Definition: Opcodes.h:599
@ SMSG_ENVIRONMENTALDAMAGELOG
Definition: Opcodes.h:538
@ SMSG_EQUIPMENT_SET_LIST
Definition: Opcodes.h:1242
@ SMSG_AURA_UPDATE_ALL
Definition: Opcodes.h:1203
@ SMSG_TRANSFER_ABORTED
Definition: Opcodes.h:94
@ SMSG_LEARNED_SPELL
Definition: Opcodes.h:329
@ MSG_MOVE_GRAVITY_CHNG
Definition: Opcodes.h:1264
@ SMSG_ITEM_REFUND_RESULT
Definition: Opcodes.h:1235
@ SMSG_STOP_MIRROR_TIMER
Definition: Opcodes.h:505
@ SMSG_CLIENT_CONTROL_UPDATE
Definition: Opcodes.h:375
#define sWorld
Definition: World.h:511
bool IsGMAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:281
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:276
uint32 GetSecurity(uint32 accountId)
Definition: AccountMgr.cpp:209
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:200
float hk_honor_at_level_f(uint8 level, float multiplier=1.0f)
Definition: Formulas.h:26
uint8 GetGrayLevel(uint8 pl_level)
Definition: Formulas.h:41
void SendCommand_Cooldown(T *o, ObjectGuid targetGUID, const char *prefix, uint32 id, uint32 dur, uint32 maxdur)
void SendCommand_UInt32Value(T *o, ObjectGuid targetGUID, const char *prefix, uint32 t)
void SendCommand_GUID(T *o, ObjectGuid targetGUID, const char *prefix, ObjectGuid t)
void apply(T *val)
Definition: ByteConverter.h:40
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:294
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const guid, uint32 typemask)
Player * FindPlayerByLowGUID(ObjectGuid::LowType lowguid)
Player * FindConnectedPlayer(ObjectGuid const guid)
Pet * GetPet(WorldObject const &, ObjectGuid const guid)
Corpse * GetCorpse(WorldObject const &u, ObjectGuid const guid)
Player * FindPlayer(ObjectGuid const guid)
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const)
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Player * GetPlayer(Map const *, ObjectGuid const guid)
std::unordered_map< std::string, Player * > MapType
LfgState
Definition: LFG.h:70
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:77
@ LFG_STATE_BOOT
Definition: LFG.h:75
@ LFG_STATE_NONE
Definition: LFG.h:71
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition: LFGMgr.h:50
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition: LFGMgr.h:53
if(MSVC) list(APPEND PRIVATE_SOURCES authserver.rc) endif() endif() if(USE_COREPCH) set(PRIVATE_PCH_HEADER PrecompiledHeaders/authPCH.h) endif() GroupSources($
Definition: CMakeLists.txt:23
float DamageMin
Definition: ItemTemplate.h:588
float DamageMax
Definition: ItemTemplate.h:589
int32 ItemStatValue
Definition: ItemTemplate.h:596
uint32 ItemStatType
Definition: ItemTemplate.h:595
uint32 Color
Definition: ItemTemplate.h:611
uint32 SpellTrigger
Definition: ItemTemplate.h:601
float SpellPPMRate
Definition: ItemTemplate.h:603
int32 SpellCategoryCooldown
Definition: ItemTemplate.h:606
int32 SpellCooldown
Definition: ItemTemplate.h:604
uint32 SpellCategory
Definition: ItemTemplate.h:605
int32 SpellId
Definition: ItemTemplate.h:600
Definition: DBCStructure.h:39
void SetActionAndType(uint32 action, ActionButtonType type)
Definition: Player.h:257
Definition: DBCStructure.h:518
int32 area_level
Definition: DBCStructure.h:525
uint32 flags
Definition: DBCStructure.h:523
uint32 exploreFlag
Definition: DBCStructure.h:522
float height
Definition: ObjectMgr.h:429
float orientation
Definition: ObjectMgr.h:430
float length
Definition: ObjectMgr.h:427
uint32 map
Definition: ObjectMgr.h:422
float radius
Definition: ObjectMgr.h:426
float width
Definition: ObjectMgr.h:428
uint32 bgQueueSlot
Definition: Player.h:998
BattlegroundTypeId bgTypeID
Definition: Player.h:996
bool bgIsRandom
Definition: Player.h:1000
bool isInvited
Definition: Player.h:999
uint32 bgInstanceID
Definition: Player.h:995
GuidSet bgAfkReporter
Definition: Player.h:1002
uint8 bgAfkReportedCount
Definition: Player.h:1003
TeamId bgTeamId
Definition: Player.h:997
Definition: DBCStructure.h:589
uint32 hair_id
Definition: DBCStructure.h:599
Definition: DBCStructure.h:603
uint32 HolidayWorldStateId
Definition: DBCStructure.h:611
uint32 id
Definition: DBCStructure.h:604
std::string const & GetText(LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false) const
Definition: ObjectMgr.h:456
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: DBCStructure.h:619
Definition: DBCStructure.h:631
uint32 bit_index
Definition: DBCStructure.h:638
uint32 GetPetNumber() const
Definition: Unit.h:1227
CommandStates GetCommandState() const
Definition: Unit.h:1231
void BuildActionBar(WorldPacket *data)
Definition: Unit.cpp:15183
CharmSpellInfo * GetCharmSpell(uint8 index)
Definition: Unit.h:1253
Definition: DBCStructure.h:642
uint32 flags
Definition: DBCStructure.h:644
Definition: DBCStructure.h:652
uint32 powerType
Definition: DBCStructure.h:655
Definition: DBCStructure.h:671
uint32 FactionID
Definition: DBCStructure.h:674
Definition: DBCStructure.h:705
Definition: DBCStructure.h:731
int32 petTalentType
Definition: DBCStructure.h:739
uint32 pickpocketLootId
Definition: CreatureData.h:128
Definition: DBCStructure.h:796
Player * opponent
Definition: Player.h:364
time_t outOfBound
Definition: Player.h:367
Player * initiator
Definition: Player.h:363
time_t startTime
Definition: Player.h:366
Definition: DBCStructure.h:839
uint32 multiplier[29]
Definition: DBCStructure.h:841
Definition: DBCStructure.h:845
float quality_mod
Definition: DBCStructure.h:847
uint32 mountSpell
Definition: Player.h:1015
void ClearTaxiPath()
Definition: Player.h:1019
WorldLocation joinPos
Definition: Player.h:1017
std::vector< uint32 > taxiPath
Definition: Player.h:1016
bool HasTaxiPath() const
Definition: Player.h:1020
ObjectGuid Items[EQUIPMENT_SLOT_END]
Definition: Player.h:737
std::string Name
Definition: Player.h:734
std::string IconName
Definition: Player.h:735
EquipmentSetUpdateState state
Definition: Player.h:738
uint64 Guid
Definition: Player.h:733
uint32 IgnoreMask
Definition: Player.h:736
Definition: DBCStructure.h:868
Definition: DBCStructure.h:900
uint32 faction
Definition: DBCStructure.h:902
bool IsFriendlyTo(FactionTemplateEntry const &entry) const
Definition: DBCStructure.h:912
struct GameObjectTemplate::@198::@203 chest
uint32 GetLootId() const
Definition: GameObject.h:548
Definition: DBCStructure.h:968
uint32 color
Definition: DBCStructure.h:971
Definition: DBCStructure.h:975
Definition: DBCStructure.h:983
Definition: DBCStructure.h:996
float cost
Definition: DBCStructure.h:997
float base
float ratio
float base
float ratio
float ratio
float ratio
float ratio
float ratio
float ratio
InstanceSave * save
uint32 reqarenapoints
uint32 reqitemcount[MAX_ITEM_EXTENDED_COST_REQUIREMENTS]
uint32 reqitem[MAX_ITEM_EXTENDED_COST_REQUIREMENTS]
uint32 reqhonorpoints
uint32 reqarenaslot
uint32 reqpersonalarenarating
uint32 maxCount
bool isContainedIn(std::vector< ItemPosCount > const &vec) const
Definition: Player.cpp:12338
uint16 pos
Definition: Player.h:749
uint32 BuyCount
Definition: ItemTemplate.h:638
uint32 DisenchantID
Definition: ItemTemplate.h:699
uint32 Quality
Definition: ItemTemplate.h:635
uint32 FireRes
Definition: ItemTemplate.h:663
uint32 ItemLevel
Definition: ItemTemplate.h:644
uint32 ShadowRes
Definition: ItemTemplate.h:666
uint32 ScalingStatValue
Definition: ItemTemplate.h:659
uint32 AllowableClass
Definition: ItemTemplate.h:642
_Damage Damage[MAX_ITEM_PROTO_DAMAGES]
Definition: ItemTemplate.h:660
uint32 GetMaxStackSize() const
Definition: ItemTemplate.h:738
uint32 FrostRes
Definition: ItemTemplate.h:665
float ArmorDamageModifier
Definition: ItemTemplate.h:694
uint32 ArcaneRes
Definition: ItemTemplate.h:667
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
Definition: ItemTemplate.h:671
uint32 HolyRes
Definition: ItemTemplate.h:662
uint32 MinMoneyLoot
Definition: ItemTemplate.h:701
uint32 MaxMoneyLoot
Definition: ItemTemplate.h:702
uint32 ItemSet
Definition: ItemTemplate.h:684
uint32 GemProperties
Definition: ItemTemplate.h:692
uint32 RequiredReputationRank
Definition: ItemTemplate.h:652
uint32 DisplayInfoID
Definition: ItemTemplate.h:634
uint32 RequiredReputationFaction
Definition: ItemTemplate.h:651
uint32 ItemLimitCategory
Definition: ItemTemplate.h:696
uint32 ScalingStatDistribution
Definition: ItemTemplate.h:658
_ItemStat ItemStat[MAX_ITEM_PROTO_STATS]
Definition: ItemTemplate.h:657
uint32 InventoryType
Definition: ItemTemplate.h:641
float GetItemLevelIncludingQuality(uint8 pLevel) const
Definition: ItemTemplate.h:766
uint32 NatureRes
Definition: ItemTemplate.h:664
uint32 SubClass
Definition: ItemTemplate.h:631
int32 getFeralBonus(int32 extraDPS=0) const
Definition: ItemTemplate.h:753
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]
Definition: ItemTemplate.h:690
uint32 StatsCount
Definition: ItemTemplate.h:656
uint32 Bonding
Definition: ItemTemplate.h:672
uint32 SpellId
Definition: LootMgr.h:313
void AddLooter(ObjectGuid GUID)
Definition: LootMgr.h:372
uint32 GetMaxSlotInLootFor(Player *player) const
Definition: LootMgr.cpp:873
ObjectGuid containerGUID
Definition: LootMgr.h:329
LootItem * LootItemInSlot(uint32 lootslot, Player *player, QuestItem **qitem=nullptr, QuestItem **ffaitem=nullptr, QuestItem **conditem=nullptr)
Definition: LootMgr.cpp:808
bool empty() const
Definition: LootMgr.h:366
QuestItemMap const & GetPlayerQuestItems() const
Definition: LootMgr.h:316
bool isLooted() const
Definition: LootMgr.h:367
void clear()
Definition: LootMgr.h:342
uint8 unlootedCount
Definition: LootMgr.h:323
ObjectGuid roundRobinPlayer
Definition: LootMgr.h:324
void generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
Definition: LootMgr.cpp:795
uint32 gold
Definition: LootMgr.h:322
void NotifyQuestItemRemoved(uint8 questIndex)
Definition: LootMgr.cpp:761
bool FillLoot(uint32 lootId, LootStore const &store, Player *lootOwner, bool personal, bool noEmptyError=false, uint16 lootMode=LOOT_MODE_DEFAULT, WorldObject *lootSource=nullptr)
Definition: LootMgr.cpp:546
void NotifyItemRemoved(uint8 lootIndex)
Definition: LootMgr.cpp:730
LootType loot_type
Definition: LootMgr.h:326
uint32 itemid
Definition: LootMgr.h:156
bool is_blocked
Definition: LootMgr.h:165
ObjectGuid rollWinnerGUID
Definition: LootMgr.h:162
bool is_underthreshold
Definition: LootMgr.h:167
int32 randomPropertyId
Definition: LootMgr.h:159
uint32 itemIndex
Definition: LootMgr.h:157
bool AllowedForPlayer(Player const *player, bool isGivenByMasterLooter=false, bool allowQuestLoot=true) const
Definition: LootMgr.cpp:406
const AllowedLooterSet & GetAllowedLooters() const
Definition: LootMgr.h:182
uint8 count
Definition: LootMgr.h:163
bool is_looted
Definition: LootMgr.h:164
bool freeforall
Definition: LootMgr.h:166
Definition: Mail.h:166
uint32 senderEntry
Definition: ObjectMgr.h:539
uint32 mailTemplateId
Definition: ObjectMgr.h:538
uint32 Expansion() const
bool IsBattlegroundOrArena() const
bool IsBattleArena() const
bool Instanceable() const
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:597
uint32 fallTime
Definition: Object.h:571
struct MovementInfo::TransportInfo transport
Position pos
Definition: Object.h:545
ObjectGuid petitionGuid
Definition: PetitionMgr.h:41
ObjectGuid ownerGuid
Definition: PetitionMgr.h:42
uint8 petitionType
Definition: PetitionMgr.h:43
float orientation
Definition: Player.h:336
PlayerCreateInfoActions action
Definition: Player.h:341
uint16 displayId_m
Definition: Player.h:337
PlayerCreateInfoSkills skills
Definition: Player.h:342
float positionX
Definition: Player.h:333
float positionY
Definition: Player.h:334
PlayerCreateInfoSpells customSpells
Definition: Player.h:340
float positionZ
Definition: Player.h:335
PlayerCreateInfoItems item
Definition: Player.h:339
uint32 mapId
Definition: Player.h:331
uint16 displayId_f
Definition: Player.h:338
uint8 stats[MAX_STATS]
Definition: Player.h:301
PlayerSpellState State
Definition: Player.h:123
bool Active
Definition: Player.h:124
uint8 specMask
Definition: Player.h:125
PlayerSpellState State
Definition: Player.h:131
bool inSpellBook
Definition: Player.h:134
uint32 talentID
Definition: Player.h:133
uint8 specMask
Definition: Player.h:132
float m_positionZ
Definition: Object.h:280
std::string ToString() const
Definition: Object.cpp:1026
float m_positionX
Definition: Object.h:278
float GetPositionZ() const
Definition: Object.h:336
float m_positionY
Definition: Object.h:279
float GetOrientation() const
Definition: Object.h:337
bool IsPositionValid() const
Definition: Object.cpp:1787
void SetOrientation(float orientation)
Definition: Object.h:329
Position GetPosition() const
Definition: Object.h:358
Position::PositionXYZOStreamer PositionXYZOStream()
Definition: Object.h:364
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Object.h:249
float GetPositionX() const
Definition: Object.h:334
float GetPositionY() const
Definition: Object.h:335
bool IsWithinBox(const Position &center, float xradius, float yradius, float zradius) const
Definition: Object.cpp:1570
void Relocate(float x, float y)
Definition: Object.h:295
uint8 index
Definition: LootMgr.h:187
bool is_looted
Definition: LootMgr.h:188
QuestStatus Status
Definition: QuestDef.h:410
uint16 CreatureOrGOCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:413
Definition: ObjectMgr.h:558
uint32 ReputationMaxCap1
Definition: ObjectMgr.h:561
uint32 RepFaction1
Definition: ObjectMgr.h:559
uint32 RepFaction2
Definition: ObjectMgr.h:560
bool TeamDependent
Definition: ObjectMgr.h:567
int32 RepValue1
Definition: ObjectMgr.h:562
uint32 ReputationMaxCap2
Definition: ObjectMgr.h:563
int32 RepValue2
Definition: ObjectMgr.h:564
AuraEffect const * ConvertAura
Definition: Player.h:405
Definition: Player.h:409
RuneType lastUsedRune
Definition: Player.h:412
void SetRuneState(uint8 index, bool set=true)
Definition: Player.h:414
RuneInfo runes[MAX_RUNES]
Definition: Player.h:410
uint8 runeState
Definition: Player.h:411
uint32 MaxLevel
uint32 Modifier[10]
int32 StatMod[10]
uint32 getArmorMod(uint32 mask) const
uint32 getDPSMod(uint32 mask) const
uint32 getFeralBonus(uint32 mask) const
uint32 getssdMultiplier(uint32 mask) const
uint32 getSpellBonus(uint32 mask) const
uint32 SkillLine
uint32 SupercededBySpell
uint32 Spell
uint32 AcquireMethod
uint32 ClassMask
uint32 RaceMask
uint32 id
uint32 SkillTierID
uint32 Flags
uint32 Value[MAX_SKILL_STEP]
uint32 itemid
Definition: Player.h:197
bool sendToSpectator
Definition: Player.h:199
bool needSendToClient
Definition: Player.h:200
uint32 end
Definition: Player.h:195
uint32 maxduration
Definition: Player.h:198
uint16 category
Definition: Player.h:196
Definition: SpellMgr.h:307
uint32 procEx
Definition: SpellMgr.h:310
uint32 customChance
Definition: SpellMgr.h:308
float PPMChance
Definition: SpellMgr.h:309
uint32 EnchantmentCondition
uint32 amount[MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS]
uint32 GemID
uint32 aura_id
uint32 spellid[MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS]
uint32 type[MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS]
uint32 ID
int16 charges
Definition: Player.h:180
SpellModOp op
Definition: Player.h:178
SpellModType type
Definition: Player.h:179
int32 value
Definition: Player.h:181
uint32 spellId
Definition: Player.h:183
Aura *const ownerAura
Definition: Player.h:184
flag96 mask
Definition: Player.h:182
uint32 attackSpeed
uint32 Row
uint32 DependsOnRank
uint32 DependsOn
std::array< uint32, MAX_TALENT_RANK > RankID
uint32 TalentID
uint32 TalentTab
uint32 addToSpellBook
uint32 petTalentMask
uint32 ClassMask
float z
uint32 map_id
float x
float y
uint32 to
uint32 from
float y
float x
uint32 mapid
float z
uint32 reqSkillValue
Definition: CreatureData.h:415
uint32 learnedSpell[3]
Definition: CreatureData.h:417
uint32 reqSkill
Definition: CreatureData.h:414
uint32 reqLevel
Definition: CreatureData.h:416
Definition: Unit.h:1169
uint32 packedData
Definition: Unit.h:1172
uint32 GetAction() const
Definition: Unit.h:1176
bool Empty() const
Definition: CreatureData.h:376
VendorItem * GetItem(uint32 slot) const
Definition: CreatureData.h:369
uint8 GetItemCount() const
Definition: CreatureData.h:377
uint32 ExtendedCost
Definition: CreatureData.h:358
bool IsGoldRequired(ItemTemplate const *pProto) const
Definition: CreatureData.h:361
uint32 item
Definition: CreatureData.h:355
uint32 maxcount
Definition: CreatureData.h:356
Definition: adtfile.h:39